My guess was to turn the image content type into a block, and if so, whats the best module to do that?

Bean

Bean is an acronym that stands for Block Entities Aren't Nodes.
This is a great introductory article about what the bean module.
What is Bean? Think of a Bean as a method to provide new types
(compared to node this would be a content type) which then provides an
add content interface to create as many blocks as you require (see
screenshot below). The bean content can then be placed around the site
just like any other block.
Beans were driven by the API first. This means that you can create
block types (bean types) all in a plugin class turning off the UI. The
entire configuration in code. No worry about feature reverts.

Here is a video tutorial
Basically it lets you add fields to blocks. This module comes with Drupal 8 core by default.


What is the proper way to return the results of custom module's form submission?

As JimaJamma noted in the comments the search module contains an excellent example of one way to do this. The search_view() function is where the magic happens, this is a custom version of that logic which should help explain the process:

function MYMODULE_menu() {
  $items['query'] = array(
    'title' => 'Query',
    'access arguments' => array('access content'),
    'page callback' => 'MYMODULE_results_page',
  );

  return $items;
}

function MYMODULE_results_page($parameter = NULL) {
  // Even if 'page arguments' isn't defined in a hook_menu() item, Drupal breaks
  // up the URL and passes arguments through to the callback function implicitly.
  // So if the page requested is 'query/123', out item defined at
  // 'query' will be used, and '123' will be passed as the first argument, in
  // this case into the $parameter var.
  //
  // If the parameter is empty, we need to check the GET/POST request to see if
  // the form has been submitted with a new search parameter.
  if (empty($parameter)) {
    if (!empty($_REQUEST['parameter'])) {
      // Build up a new path based on the submitted parameter.
      $path = 'query/' . $_REQUEST['parameter'];

      // And re-direct there. The request will come straight into this function
      // again, but this condition won't fire.
      drupal_goto($path);
    }
  }

  // Now we're in a position to query for results if there's a non-empty
  // parameter. Otherwise we just show the form (like the search page we'll
  // show the form unconditionally).
  $results_build = array('#markup' => '');
  foreach (MYMODULE_get_results_by_parameter($parameter) as $result) {
    $results_build[] = MYMODULE_build_result_render_array($result);
  }

  $build = array(
    'form' => drupal_get_form('MYMODULE_query_form'),
    'results' => $results_build,
  );

  return $build;
}

function MYMODULE_query_form($form, &$form_state) {
  // Make we're submitting to the right path.
  $form['#action'] = 'query';

  $form['parameter'] = array(
    '#type' => 'textfield',
    '#title' => t('Enter query here'),
  );

  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Submit'),
  );

  return $form;
}

I haven't tested that or anything so excuse any small bugs. If there are any bugs hopefully the comments, and the comments in the search_view() function, will do enough to help explain what should be happening :)


Your code needs to be adjusted to something like:

function tubitekuz_form_alter(&$form, &$form_state, $form_id) {
  switch($form_id) {
    case 'webform_client_form_97':
      global $user;
      if ($user->uid > 0) {
        $form['submitted']['kullanici_adi']['#access'] = FALSE;
      }
      $form['submitted']['kullanici_adi'] += array(
        '#prefix' => '
',
        '#ajax' => array(
          'callback' => 'kullanici_adi_form_login',
          'wrapper' => 'kullanici-adi-container',
        ),
        '#suffix' => '
',
      );

      // Check the form state to see if an e-mail address has been specified.
      if (!empty($form_state['values']['kullanici_adi'])) {
        $mail = trim($form_state['values']['kullanici_adi']);

        if ($account = user_load_by_mail($mail)) {
          form_set_error('submitted][kullanici_adi', 'Kullanıcı adı kayıtlı, lütfen başka bir kullanıcı adı seçin');
        }
      }
      break;
  }
}

function kullanici_adi_form_login($form, $form_state) {
  return $form['submitted']['kullanici_adi'];
}

You will probably have to play around with some of the arrays, etc. to get the correct values, etc.


how to load my css and js first on drupal 7

My advice is that you enable the responsive grid and then you could apply CSS to the site by using the following basic format. If you read my inline comments, I think you'll get the gist of it.

There is an alternate way to do this where each breakpoint's css is put in its own file. This involves adding some lines to your subtheme's .info file and is pretty well documented here.

This approach may seem overwhelming to you (it did to me at first), but you'll be making a responsive site (one that looks good on all devices) which is a really great skill to have. You test the different breakpoints by resizing your browser window or using browser developer tools. You should also test on actual devices, but I do my initial design and testing by just resizing my window.

/*CSS for genchstyle theme - all breakpoints*/

/*GLOBAL STYLE INFO FOR ALL DISPLAY BREAKPOINTS*/

    h2 {
    color:rgb(204,204,204);
    font-family:Arial,Helvetica,sans-serif;
    font-size:1.2em;
    }

/*MEDIA QUERIES FOR RESPONSIVE DESIGNS*/

/*Wide - larger computer screens and retina devices*/
@media all and (min-width: 1200px) {

    body{
    background:#000 url(../../../../default/files/grate-wide.jpg) repeat;
    background-attachment:fixed;
    width:100%;
    font-size:100%;
    }

}

/*Normal - iPad horizontal & small-to-medium computer screens*/
@media all and (max-width: 1200px) {

    body{
    background:#000 url(../../../../default/files/grate-normal.jpg) repeat;
    background-attachment:fixed;
    width:100%;
    font-size:100%;
    }

}

/*Narrow - iPad vertical & kindle fire, etc.*/
@media all and (max-width: 960px) {

    body{
    background:#000 url(../../../../default/files/grate-narrow.jpg) repeat;
    background-attachment:fixed;
    width:100%;
    font-size:90%;
    }

}

/*Fluid - Small Mobile Devices & smart phones*/
@media all and (max-width: 720px) {

/*Background - mobile*/

    body{
    background:#000 url(../../../../default/files/grate-fluid.jpg) repeat;
    background-attachment:fixed;
    width:100%;
    font-size:90%;
    }

}

You can see this in action on the site I'm building (it's an omega subtheme).

I love Omega and I think you made a really smart choice basing your subtheme on it. But it's the responsive grid that makes it great! Just my opinion.

Oh - and I'm just naming this css file global.css and I'm storing it in my sites/all/themes/mytheme/css directory.


40 fields on a single content type sounds a lot to me, although I'm aware of sites with a great deal more.

The very first thing you probably want to to, is use Entity Cache which should significantly reduce the query complexity for you, though honestly I haven't examined the module in detail.
Aggresively cache higher up the chain as well. Varnish, Page manager and Cache actions are all your friends here.
Is it possible for you to meaningfully break down the content type into pieces? If you can identify parts of the content type that will not always be necessary, use a Relation to a second content type. At the price of two optional extra joins, you can potentially skip a lot of them.
Still no luck? Define your own content type where all your data columns are properties instead of fields. This will store all data in the same table, at the cost of flexibility. It's probably also possible to make field api do the same thing with fields, but I have never even considered how to do that.


How do I use the Rules module to unpublish content when End Date is hit?

I have this functionality on a D7 site I run, and we use the Scheduler module instead. Looks like there is an alpha release for D8 you could try: https://www.drupal.org/project/scheduler


Just to be sure, are you calling views-embed-view(), or views_embed_view() (Note the dashes/underscores). The second version (views_embed_view() is the correct one).

Also, how do you call the function? Which parameters do you pass?

As per this page, the correct way of embedding a view is 1 of the following ways.

Option 1:

// Get the embeded view and render it.
drupal_render(views_embed_view('VIEW_NAME', 'DISPLAY_ID'));

Option 2

// Get the embeded view and render it.
\Drupal::service('renderer')->render(views_embed_view('VIEW_NAME', 'DISPLAY_ID'));

In this example you will have to replace VIEW_NAME with the machine name of your view, and the DISPLAY_ID should be replaced with the ID of the display you want to use (Or can be omitted to use the default display).

Also note that the second option is the better one, since the drupal_render function is deprecated, and will be removed before Drupal 9.0.0 (More info).


The easiest is to just put a formula into a spreadsheet and alter your source csv.

Else you could write your own feeds tamper plugin.

Create an empty file called 'stock.inc' and place it into the feeds_tamper/plugins directory. Add this to it:

<?php
$plugin = array(
  'form' => 'feeds_tamper_stock_form',
  'callback' => 'feeds_tamper_stock_callback',
  'name' => 'Calculate stock',
  'multi' => 'direct',
  'category' => 'Other',
);

function feeds_tamper_stock_form($importer, $element_key, $settings) {
  return array(
    'help' => array(
      '#markup' => t('Sets the stock status'),
    ),
  );
}

function feeds_tamper_stock_callback($result, $item_key, $element_key, &$field, $settings, $source) {
  $field = $result->items[$item_key] > 0 ? 'In Stock' : 'Out of Stock' ;
}

Clear your cache.

I have not tested this but I believe it will get you close.


Appending a hidden input value to a textarea value?

Here is a little example (Additional information):

function my_form($form, &$form_state) {
  $form['name'] = array(
    '#title' > 'Name',
    '#type' => 'textfield'
  );

  $form['sec_name'] = array(
    '#title' > 'last name',
    '#type' => 'textfield'
  );

  $form['submit'] = array(
    '#value' > 'Run',
    '#type' => 'submit'
  );

  return $form;
}

function my_form_submit($form, &$form_state) {
  $f_name = $form_state['values']['name'];
  $s_name = $form_state['values']['sec_name'];

  drupal_set_message('Hello ' . $f_name . ' ' . $s_name);
}


Views, adding I like, Retweet - best approach

I also searched for modules that would allow Social Sharing - what I ended up doing was just adding the code manually to the templates.  It's just a couple lines of javascript, usually.  I ended up using AddThis for the main group and then just pulled the Facebook like code from their website.

IMO, somtimes a module is overkill.


How can I print the views title in node.tpl.php?


The lock system is initialized during bootstrap (during the DRUPAL_BOOTSTRAP_VARIABLES phase, which follows the DRUPAL_BOOTSTRAP_DATABASE one) using the following code.

// Initialize the lock system.
require_once DRUPAL_ROOT . '/' . variable_get('lock_inc', 'includes/lock.inc');
lock_initialize();

You could:

Bootstrap Drupal to the DRUPAL_BOOTSTRAP_DATABASE phase
Change the value of the lock_inc Drupal variable to make it point to an include file containing your implementation of the lock system, with functions that don't do anything
Execute the rest of the code, including the one to raise the bootstrap level to the desired one

Since you are loading other modules, this resolves the problem with the lock database table, but it doesn't avoid that modules try to access a database table that normally exists on a Drupal installation, including the ones they install. If you need to execute a query (for example, a SELECT) on a database that is different from the default one you could use the following code.

Database::addConnectionInfo($db_alias, 'default', $test_database);
query = Database::getConnection('default', $db_alias)->select('table name', 'table alias');
// The rest of the code goes here.

The first two arguments for Database::addConnectionInfo() and Database::getConnection() are flipped: The first argument of Database::addConnectionInfo() becomes the second argument of Database::getConnection(), and the second argument of Database::addConnectionInfo() becomes the first argument of Database::getConnection().


How to delete all Persistent variables when a page is loaded?

It is considered bad practice to delete all the persistent variables whose name starts with the short name of the module. There could be a module whose short name starts with that short name; in that case you would be removing the persistent variables of that module.
For example, given the Views module, there could be a Views Enhancer module. Deleting all the persistent variable matching the SQL pattern '%views_%' would mean deleting the persistent variables of both modules.

Instead, you should have a list of all the persistent variables your module uses. (That is not hard, since you are writing the code of your module.) Using that list (for example, contained in $variables), a code like the following would delete all the variables.

  global $conf;

  db_delete('variable')
    ->condition('name', $variables, 'IN')
    ->execute();
  cache_clear_all('variables', 'cache_bootstrap');

  foreach ($variables as $name) {
    unset($conf[$name]);
  }

This is, essentially, the code of variable_del() adapted to delete a list of variable names contained in $variables.

You could also use that code to implement a function your module uses.

function variable_delete_multiple(array $variables) {
  global $conf;

  db_delete('variable')
    ->condition('name', $variables, 'IN')
    ->execute();
  cache_clear_all('variables', 'cache_bootstrap');

  foreach ($variables as $name) {
    unset($conf[$name]);
  }
}


Categories or Paragraphs are just references when you create a node view.
Thus when you use them in the fields (as output) they are not sortable but you can add a relationship to them and then their individual fields (like name, id etc) become sortable

Here is an example with tags (on article content type)

Added term relationship Taxonomy terms on node and then tag id and tag name are sortable (among others)

ΝΟΤΕ: you will most certainly end up with duplicate results in the view. For this you can use aggregation, "Group results together" with group column "entity id".


Go to /modules/search/ to find the templates you want to override. Copy/paste them to the 'template' folder inside your 'theme' folder. Make sure you clear the caches so Drupal knows what you have done. Thats all there is to it.


I get a "URL not found" error, but the image is on the server

If you have some sort of caching service like "Varnish" active you may want to try clearing it's cache.

This sometimes happens to me and I just need to clear my browser's cache.


How to work with field collections in $build in hook_entity_view_alter?

HOOK_entity_view_alter() works with render elements. That are all array keys, that have no '#' sign.

At the point you are now there are only fields prepared for rendering on the top level, that means the fields, which are not in a field collection.

Fields that are inside a field collection have at this point no renderable output.

To get the render elements of these fields you have to use the hook for field_collection_item:

function mymodule_field_collection_item_view_alter(&$build, $entity, $display) {
   kint($build);
}

Here you will be able to unset fields inside the field collection.


Does "Boost" module work together with "Theme Key" module?

The two work well together (Does ThemeKey supports Boost caching) with the caveat:

  ThemeKey supports page caching and external caches like boost - if the
  page is cachable.

  If you switch a theme depending on the user's browser, the page isn't
  globally cachable at all, because other users are using different
  browsers! That's not a ThemeKey issue.


URL aliases and Entity Translation (menu name replacement pattern)

Instead of using [node:menu-link], use [node:title] instead.


How to a use a template file to theme a form?

It's completely reasonable to want to use a tpl file to display a form. You can use lots of extraneous CSS and #prefix/#suffix properties to achieve similar results, but by using tpl's you don't have to clutter up the separation of your logic and presentation layers and don't have to target ugly CSS selectors like #user-login label. Here's an example in Drupal 7...

mytheme/template.php:

function mytheme_theme($existing, $type, $theme, $path) {
    // Ex 1: the "story" node edit form.
    $items['story_node_form'] = array(
        'render element' => 'form',
        'template' => 'node-edit--story',
        'path' => drupal_get_path('theme', 'mytheme') . '/template/form',
    );

    // Ex 2: a custom form that comes from a custom module's "custom_donate_form()" function.
    $items['custom_donate_form'] = array(
        'render element' => 'form',
        'template' => 'donate',
        'path' => drupal_get_path('theme', 'mytheme') . '/template/form',
    );

    return $items;
}

custom_donate_form():

function custom_donate_form($form, &$form_state) {
    $form['first_name'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('First name')),
    );
    $form['last_name'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('Last name')),
    );
    $form['address'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('Address')),
    );
    $form['city'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('City')),
    );
    $form['state'] = array(
        '#type' => 'select',
        '#options' => array(
            'default' => 'State',
            '...' => '...',
        ),
    );
    $form['zip'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('Zip')),
    );
    $form['email'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('Email')),
    );
    $form['phone'] = array(
        '#type' => 'textfield',
        '#attributes' => array('placeholder' => t('Phone')),
    );
    $form['submit'] = array(
        '#type' => 'submit',
        '#value' => 'Submit',
    );

    return $form;
}

mytheme/template/form/donate.tpl.php:

Contact Information

                <?php print render($form['first_name']); ?>

                <?php print render($form['last_name']); ?>

                <?php print render($form['address']); ?>

                <?php print render($form['city']); ?>

                <?php print render($form['state']); ?>

                <?php print render($form['zip']); ?>

                <?php print render($form['email']); ?>

                <?php print render($form['phone']); ?>

            <?php print render($form['submit']); ?>

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

This is using Foundation, which gives us a form like this:


You need to create a new Server Block for the new domain.

This is the file that NGINX reads in order to determine where it will look for the site when a request for a domain come through.

The configuration will be under

/etc/nginx

The relevant/current entry could be in nginx.conf, in a file under conf.d or sites-available.


Matrix view with content as columns and taxonomy terms as rows

It can be achieved with the help of hook_views_pre_view() and the Views field template file.

Create a View

Create a view showing content in table format and add two fields:

Content: Title (Title)

The title will populate each row of the first column.

Content: All taxonomy terms (All taxonomy terms)

select: Exclude this field from display

select: Limit terms by vocabulary and tick the vocabulary you want to use.

Your module file

Create a column for each term and populate all the fields with the value from the field Content: All taxonomy terms (All taxonomy terms) Then we'll be able to check if a comma-separated list of terms contains the term of the current column.

/**
 * Implements HOOK_views_pre_view().
 *
 * Adds a field to the "YOUR VIEW NAME" view.
 */
function YOURMODULE_views_pre_view(&$view) {

  if ($view->name == 'YOUR_VIEW_NAME') {
    // the vocabularies defined in the view.
    $vocabularies = array_filter($view->display['default']->handler->options['fields']['term_node_tid']['vocabularies']);
    $terms = YOURMODULE_terms($vocabularies);
    $count = count($terms);
    for ($i=0;$i<$count;$i++) {
      // define the field id.
      $view->display['default']->handler->options['fields']['tid_' . $i]['id'] = 'tid_' . $i;

      // define the table (it has to be the same table for all fields)
      // if you aren't sure what the table name should be, uncomment the line below and take a look at the first field data.
      // debug($view->display['default']->handler->options['fields'], 'VIEW FIELDS', TRUE);
      $view->display['default']->handler->options['fields']['tid_' . $i]['table'] = 'node';

      // here we need to define our custom field output
      // the field "Content: All taxonomy terms (All taxonomy terms)" has a mashine name 'term_node_tid'
      // this field need to be excluded from display because we do not want to display one column only.
      // Instead we will use the data to populate all our custom fields, then we'll be able to define the output for each of them.
      $view->display['default']->handler->options['fields']['tid_' . $i]['field'] = 'term_node_tid';

      // define the field label
      $view->display['default']->handler->options['fields']['tid_' . $i]['label'] = $terms[$i];

      // we need only term names, not links.
      $view->display['default']->handler->options['fields']['tid_' . $i]['link_to_taxonomy'] = 0;
    }
  }
}

A helper function that returns an array of terms. This function will be used twice. First time in hook_views_pre_view() where the argument is available from the View. Second time in YOURMODULE_has_term() where the argument would be hardly to get. That's why I decided to use a static variable here.

/**
 * Helper function that returns an array of terms.
 *
 * @return array
 *   An array of terms from all vocabularies (defined in the view).
 */
function YOURMODULE_terms($vocabularies = NULL) {
  $terms = &drupal_static(__FUNCTION__);
  if (!isset($terms)) {
    $terms = array();
    foreach ($vocabularies as $key => $vocabulary) {
      $vid = taxonomy_vocabulary_machine_name_load($vocabulary)->vid;
      $taxonomy_tree = taxonomy_get_tree($vid);
      foreach ($taxonomy_tree as $term) {
        $terms[] = $term->name;
      }
    }
  }
  return $terms;
}

A helper function to determine if a field value (comma-separated list of terms) contains the term of current column. This function will be used in a Views field template file.

/**
 * Determines if a comma-seperated list of terms contains the term of the
 * current column.
 *
 * @param $field_alias string
 *   The field alias corresponding to the $field->field_alias value in the view.
 * @param $field_position integer
 *   The column corresponding to the $field->position value in the view.
 * @param $output string
 *   Comma seperated list of terms.
 * @return 'X' if TRUE or bool if FALSE.
 */
function YOURMODULE_has_term($field_alias, $field_position, $output) {

  // because we are using two fields to provide the data
  // we need to skip two positions to get appropriate term keys.
  $field_position = ($field_position > 1) ? $field_position-2 : $field_position;

  // because this is a second call for this function,
  // we don't need to define vocabularies as an argument.
  $terms = testmodule_terms();

  // each column has their own term name.
  $term_name = $terms[$field_position];

  // first column fields.
  if ($field_alias == 'node_title') {
    return $output;
  }

  // the fields in all terms columns.
  else {

    // explode terms and trim whitespaces.
    $term_names = array_map('trim',explode(",",$output));

    // check the term names array contains the term of the current column.
    if (in_array($term_name, $term_names)) {
      return 'X'; // check mark
    }
    return FALSE;
  }
}

Views field template file

Create a View template file views-view-field--[YOUR-VIEW-NAME].tpl.php and place in your templates folder.

<?php
// We're assuming that this view only has two fields (Content: Title)
// and  Content: All taxonomy terms (All taxonomy terms).
// All other fields are generated by the HOOK_views_pre_view() function in the
// `YOURMODULE.module` and those should be passed through the
// `YOURMODULE_has_term` function which determines if the $output
// (comma-seperated terms) contains the column term name.
print YOURMODULE_has_term($field->field_alias, $field->position, $output);
?>

I was able to answer this question thanks to a similar post here and added lots of comments to the code. Hope it helps.


How do I configure meta tags for a panel page?

I have the same requirement and one of the patches attached in the issue titled "Panels / Page Manager integration" worked for me. This patch basically adds a module of panel pages which when enabled, provides interface to configure meta tags for each panel pages under /admin/config/search/metatag.


How do I programmatically add a field to an existing fieldset that's part of the user entity?

I think you should try hook_form_alter. try this may it helpful to you.

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

  // Check your form-ID
  if ($form_id == 'user_profile_form') {
    // Creating custom field
    $form['new_field'] = array(
      '#weight' => 4,
      '#type' => 'textfield',
      '#title' => t('New Field Name'),
    );
  }
  // Attach to the existing group
  // Suppose group machine-name is group_general
  $form['#group_children']['new_field'] = 'group_general';
}


Drupal 7: View filters impact on performance

In general having more views will effect the performance of your site. However you can check the view query / render etc at the bottom of the view edit pages which should give you insights into what degree they effect performance. You can also cache views but it means there will be a lag on content updates being shown by the view.

In general you will also find more modules you add to drupal will have a performance impact although it could be slight. Even adding views to pages will add js and css and thus the more page weight so it will take longer to download. Also views run will have more db queries and have a performance impact on the database.

Was there something in particular you were looking for?


How to display date and time inside a form #markup?

Sounds like you want to use the format_date() function.

$now = time();
$date = format_date($now, 'short');

You can use it with any of the date formats that are defined in your system, or you can pass in a custom date string.


How can I allow editors to manage many taxonomies while choosing which terms to boost and which to make visible?

My preference is to use 3 fields. I'm not sure I think it's ideal, but I think it's actually an easier UX and a better data structure than 1 field (or subentity) with taxonomy ref plus additional checkboxes for primary and display with each tag.

On the surface, it may seem like 1 field would be better, but I think that's actually an illusion. The two main users I'd consider here are developer and editor, and I think one complicated field is bad for both of them. For developers, it's going to be more difficult to determine the search terms or display terms when you try to get them in code with one complicated field vs 3 separate fields. It's also going to be more difficult for editors, they won't be able to scan and see all search terms or all display terms easily.

Field 1: Tags
This is the master field, it has all the tags that would be in either of the other two fields. If you're generally checking if the content has a tag, you'd check here.

Field 2: Display Tags
This field is a subset of Field 1 tags and its only purpose is determining which tags display.

Field 3: Search Boost Tags
This field is also a subset of Field 1 tags and its only purpose is boosting search results.

Custom Field Widget
Create a new field widget to be used with the display tags and search boost tags fields. This widget displays tags with checkboxes and is limited to only the tags in the first, master tags field. Also have the widget update its options via ajax whenever the first tag field changes.

This approach creates an easy interface for editors, keeps all the data easily accessible for developers, and limits special custom coding to just the field widget. (Bonus: you now have a cool field widget in your collection that you can use elsewhere in similar situations.)


File attachments in /files/ disappearing

We are having a similar issue (http://deepcarbon.net), and it is intermittent. Most of the time it all works. But sometimes the images simply disappear. They were in the database, they were in the file system. Then all of a sudden they were not. Wondering if there's anything new on this topic.

So I know that the files table in the database has a status column. If the status is 0 (temporary) then the file will be removed the next time the cron runs. The other status is 1 (permanent).

I'm also curious about what jdu says "I would suggest bootstrapping drupal and manually running some of drupal's image functions to test it out". Can you explain that more? What functions?

So our current solution is to run a cron every night to determine if any files have been removed from the filesystem since the night before. And we archive the files directory, so we can restore them if need be. At least until the real problem

We've also turned on creating revisions for every change for every content type, so we know when someone does something in a node.

So far we have not had the problem again over the last 3 weeks, so debugging this issue is on hold.


Why when I do a configuration export does the config.tar.gz in tmp not get copied to the sync folder?

The best way to store configuration is to store it outside of Drupal root directory.

For example you will have next project structure:

Where:

config/sync is a directory with your sync configuration.
public_html is a directory with your Drupal 8.

In your setting.php just add this

$config_directories['sync'] = '../config/sync';

And export your active configuration using drush

drush cex

That's all. In config/sync directory you will a files list of all your configuration.


Views won't handle my pathauto pattern for taxonomy pages

Yes - you're very close on this, but you're right that the pathauto path is not being recognized by views here. To overcome this, you're going to need to add a 'default argument' in your views argument handling code and use PHP code to pass the term id from the end of your string.

It looks like from the version of tokens you are using that you're on Drupal 7 / Views 3, correct? If so, you're going to want to add this under

Contextual Filters -->
Content: Has taxonomy term ID -->
Provide Default Argument -->
PHP Code

and then in the php code section add this code:

$path = isset($_GET['q']) ? $_GET['q'] : '';
$path = explode('/', $path);
return $path[3];

This gets the current path as an array and returns the 3rd element, or the TID and passes it to your view.


drupal 7 on virtual server with debian linux - inconsistent response time

500 MB is not much, unfortunately :)
and the default debian settings for Apache and MySQL are prepared for bigger servers. You should make sure the server doesnt swap.

Probably the most important setting for that is in the part mpm_prefork_module in the apache configuration (/etc/apache2/apache2.conf). You will want to have less Startservers, MinSpareServers and MaxSpareservers.

Installing APC helps, too (and is relatively easy). Even though you have to sacrifice some RAM, it speeds up the loading and reduces the RAM needed for every pageload. With 500MB, you will want to use APC only as opcode. Make sure you dont use much more stuff than 1 installation of drupal, or set APC so that other stuff doesnt get cached (the default settings caches every php file you use, thus probably pushing the important stuff away).

Enable the css + js aggregation - apart from saving roundtrips for the client, it also saves your server from serving extra files.

Also take into account that drupal does some caching internally and the times when it takes longer may be because of that - it is useful to "prime" the caches ie by crawling all pages before you start measuring.

2bits have great articles about optimizing for drupal.


I haven't attempted this myself, but I would assume you can pass the current selected language in as a context and then trigger different variants of the panel based on that.

You could then also trigger individual pane visibility based on the current language (i.e don't show this untranslated pane to German visitors).


How to export Panels Everywhere template code to a module

You can try features module.

The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case.
Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its .info file so that it can be checked, updated, or reverted programmatically.

the features module converts every entity (views, content types, ...) in to a module and it can easily be installed and modified every where.


How to show comments for an unpublished node

I vaguely remember I had once an issue with viewing unpublished content and the view_unpublished module offered me a better granularity that solved my issue.

Otherwise I would say creating a view showing comments in relation with the node, using a contextual filter nid, and without the filter "content: published" might help.


Change the node edit link for a specific content type

You can use hook_node_prepare, Please check the below code which can help you to sort out your problem.

function hook_node_prepare($node) {
if($node->type == "somecontent type"){
    drupal_goto("/somepath..");
}

}


Messages are stored in the session (errors, warnings and info messages). If anything is in the session, a session cookie is set in the browser. If the session cookie is set in the browser, Varnish is normally bypassed.

Note, the name of the Drupal session cookie is SESS followed by a long hexadecimal string.


How can I make Private Messages in Drupal 7 with user user pictures like in Facebook?

that's a great idea, I would love to see that too. Wouldn't it be easier replacing the default page with a view? Then you can style it any way you want. The "checkboxes" and actions could be done with VBO.


Allow tinymce in WYSIWYG to load different skins per content type

I think you're on the right track, but from memory, I don't think you'll have info about the content type or the node form in the $settings and $context variables, As Darvanen suggests.

I'd implement hook_form_alter() to match node forms, then read the content type being used, and store it as a static variable through drupal_static() function. That way you can access the content type info from the snippet you pasted above, using that same drupal_static() function, and then choose which skin to use.


How do I create separate node/add forms for different uses and for the same content type?

You can use panels to create different a different views of the node add/edit forms. I've done something similar before but I had to add a query string to the URL and show the different view that I had setup. I will try to update with more information later.

Update with Instructions of how this can be done

Here is an overview of how I achieved this before. I used panels Panels and Context modules to set up this and show two different views for the node edit forms (Keep in mind your required fields will need to be present but this is just an overview of how you can achieve something like this.) First, some knowledge of both of these modules will be needed but you can learn as you go. First thing that I knew I needed was exactly what you said, two different node edit/add views where different fields showed at different times depending on the job being accomplished. I am going to run through a simple scenario that probably won't make much sense but it will show that it can be done with using these two powerful modules together.

First, I set up a context based on a query string. Go add a context in the context UI and add a condition based on query string. Then place your query string (mine is "view=maintenance") and not sure if you have to but I went ahead and added a body class by theme HTML in what the context does (you will see that in the context UI but you are going to really use this context in panels so just save it to use later).

Next go to Page manager and there is a page that you can use called Node Edit, you will need to turn this on and create your variant. You will want to choose node type in the context and restrict this to only the content type you want this to work with since it is specific to just that node edit form. For one of my views I wanted the whole form was needed. Use add content, Forms, and add general form. Now you have the form you had before just being controlled by panels. You will want to add a visibility rule and choose PHP code for the visibility rule. Then you can use the code below to find out if your context is present (Use Not if you want the full form to show without the query string).

$contexts_module = context_active_contexts();
if (array_key_exists('machine_name_of_context', $contexts_module)) {
  return TRUE;
}

So now you have the full form showing with or without the query string. At this point the form should not show on the other context. This is the only part that I don't really like but it works and its been the only way without writing a whole bunch of code that I have found can be flexible enough for others to change after I hand a site off to a client. You will have to add the fields that you want to show when the query string is present or not present (depending on what you chose earlier) and copy the code from above and either choose NOT or not choose NOT and also add the node submit buttons and choose that as well. (You of course can set each field up and hide the fields you want according to the query string or some other way, just play around with it until you learn it and understand what it can do).

I'm not really great at writing these instructions but hopefully you understood what it can do and how to do this. I will try to revise them over time to help future viewers. I am also including some screenshots below that will show this in action.

Context UI Query String setup

Panel variant for clarity

This shows the whole form when the query string is present

This is the not code, so when query string isn't present show this

Shows url query string but (a partial screen shot) full form is shown to user

Shows form trimmed down for normal use


What Continuous Integration System is most geared?

Among open-source PHP projects, the two most widely-used CI implementations are easily Jenkins (jenkins-ci.org) and Travis (travis-ci.org). Both have significant communities, and you can find examples of using them with Drupal (eg wiki.jenkins-ci.org/display/JENKINS/Drupal+Development and www.vmdoh.com/blog/how-we-test-drupal-7-modules-travis-ci).

Between the two:

Jenkins' positioning is more like Drupal's -- it's an open-source product with a lot of add-ons/options/features, but you have to think a lot about deployment and picking options. It's useful for testing and many other things (e.g. deployment, nightly tarballs, cron-jobs).
Travis is a proprietary SaaS offered on a freemium basis -- free for public/FOSS code; paid otherwise. It's generally easier to setup because Travis provides servers and bundles more features in the default. It has a more focused/limited range of use-cases.

For some specific features that differentiate them (at time of writing):

Jenkins provides reports -- e.g. when a test fails, it lists out specific failures on a nice web-page. You can see an example of a full report at https://test.civicrm.org/job/CiviCRM-Core-Matrix/CIVIVER=4.5,label=test-debian6-1/lastCompletedBuild/testReport/ . In Travis, this is a long-standing feature-request: https://github.com/travis-ci/travis-ci/issues/239
Travis makes it relatively easy to test with different combinations of key dependencies (e.g. PHP 5.2+5.3+5.4+5.5 and MySQL 5.1+5.5+5.6). In Jenkins, this is possible but requires much more sysadmin skill.

As a rule of thumb:

If you have a large project (with lots of code, lots of tests, peculiar integrations, some budget), then Jenkins' deeper feature-set and configurability make it the better choice.
If you have a small project published on Github (e.g. an individual Drupal module or PHP library with no budget), then Travis's simplicity and bundling make it the better choice.
If your project is in between, then there is no clear rule of thumb; it's a judgment call.

Aside: You may find buildkit.civicrm.org interesting. The summaries and explanations are written for an audience that works with Drupal/Joomla/WordPress, although a lot of technical details would need tuning for a Drupal-only audience (e.g. replace "civibuild" with "drush"; replace "Build Types" with "makefiles").

(NOTE: I left several links as plain-text because stackexchange limits the #links from new users.)


Importing data into specific fields from CSV - into pre-existing nodes?

Feeds requires you to map a unique identifier in order to update existing content; I've not tried this but presumably if your existing content has a unique field/property which you can map to your import then you will be able to update existing content.


You could also just use hook_menu_local_tasks_alter() in D7:

function MYMODULE_menu_local_tasks_alter(&$data){
foreach ($data['tabs'][0]['output'] as $key => $value) {
        if ($value['#link']['path'] == "user/%/view"){
            unset($data['tabs'][0]['output'][$key]);
        }
    }
}

Documentation


You need to use this format for drupal to recognize the template for that content type.

page--machine_name.tpl.php

The machine name should be displayed on your YOUR_SITE_NAME.com/admin/structure/types page.


Customizing system response emails outside of the admin panel

You can use tokens (provided by the Token module) in administrative e-mails.  If you need a token for a value not provided by the Token module, you can programatically create a token.


Creating a token for the image field file path with node reference nid

The answer is using the Fieldfield Paths module.

  The FileField Paths module extends the default functionality of Drupals core Upload module, the FileField module and many other File Upload modules by adding the ability to use node tokens in destination paths and filenames.


How to set up menu with links to pages in different languages on multilingual sites?

How about using "language neutral", or "Indépendant de langue" in French? That's an option you should have on the node "edit" form ("modifier" in French) for each of those 3 pages. And then combine this with creating a (single) menu link, in the appropriate menu of course.

That should make such link show up for both languages. That's how I always implement such pages, typically for pages similar to the ones you mentioned. Or sometimes in cases where some translation is still missing, and at least such page should be shown already in another language for which its content is available already.

FYI: I'm also using "determine language from the URL path").


Site Time Zone = field time zone but != database time zone

When entering data into the field, the data entered is assumed to be in the site's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for anonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.
More info https://www.drupal.org/node/767182


Calculate Database Field Value and Send to Views as New Field

Take a look at this, it shows how you can create custom fields that you can use within views https://www.webomelette.com/creating-custom-views-field-drupal-8

I've followed this recently and seems to work well


Commerce Coupons, Discounts, and Tax not appearing on Checkout Review page

Solved! Rules was the culprit. By rolling back to the previous stable version, all of the problems with checkout disappeared. Everything applies correctly to the Checkout Page, and is still there when I get to Checkout Review.

Just to be clear, I replaced the current stable version of Rules (7.x-2.8) from January 2015 with the previous stable version (7.x-2.7) from May 2014.


You could probably try the alternative module Sitemap. They fixed the ordering issue in their latest version (7.x-1.3).


Is there any way to reset a menu's default order (e.g. Management Menu)?

Not that i'm aware of.

It sounds like the mega menu being active is firing something like a hook_menu_alter to be evaluated by Commerce -- they've hardcoded their own ordering because its more "user friendly".

hook_menu_alter overwrites values that the menu had, so drupal has no knowledge what the default ordering was. If the mega menu is active it forces their ordering, if it isn't you get the default ordering.

You'd have to look in Commerce where they add the custom menu items, or activate the mega menu and see how their adjusting menu #weight values.

You could then write your own hook_menu_alter that undoes their changes.


What's the proper way to create a new page option?

The easiest way to to use Views.

You can create a view over Comments, or you can make a view over Content and then add a relationship to the node's comments.  There are advantages and disadvantages to both.  You just need to play with them to see what works best for your situation.

With either method, you can use any of the normal means for adding a view to you site.


You need to set access to FALSE.

function MYTHEME_node_view($node, $view_mode, $langcode) {
  if(isset($node->content['field_members_only']) && count($node->content['field_members_only']) && $node->content['field_members_only']['#items']['0']['value']=="0") {
    $node->content['field_members_only']['#access'] = FALSE;
  }
}


How to create a Class that I can reuse in multiple modules?

Your use case is where Drupal 8 services come into play. When you'd like to create classes/methods that can be used across Drupal by other modules and your theme, create a custom module that provides this class as a service. You can then get an instance of this service class by either using the static service getter \Drupal::service() within *.module or *.theme files, or dependency injection in other classes/services.


jQuery only effecting first node in slideshow

If you are trying to affect all nodes within the view, why not iterate over all the nodes using jQuery to add your class? Ex.: $('selectors for nodes inside view').addClass('textfill'); This is like calling .each(), except the iteration is implicit. Then, after you search the DOM and add the classes you want, call $('.textfill').textfill(); .


Adding repositories in contrib module composer.json?

Comments above pretty much answer this. No what I was looking to do is not possible.


Creating commerce users programmatically

you got 2 options 1 migrate them, such as (https://www.drupal.org/project/migrate_source_csv)
 or make an admin form to submit the csv file and get the content...
but really you need to be create profiles for this billing info...

// Save user account.
$user->save();
// Add billing info.
$the_user_created_id = $user->id();
$profileStorage = \Drupal::entityTypeManager()->getStorage('profile');
$profile_data = [
 'type' => 'customer',
 'uid' => $the_user_created_id,
 'status'=> 1,
 'address' => [
   "langcode" => "",
   "country_code" => "AU",
   "administrative_area" => "NSW",
   "locality" => "SOME PLACE",
   "dependent_locality" => null,
   "postal_code" => "2000",
   "sorting_code" => null,
   "address_line1" => "Some Street",
   "address_line2" => "",
   "organization" => "47",
   "given_name" => "firstname",
   "additional_name" => null,
   "family_name" => "lastname",
  ],
];

$new_profile = $profileStorage->create($profile_data);
$new_profile->save();


How can I sell time slots using drupal Commerce?

Looks like you are looking for Commerce Booking:

  This module provides tools to use Drupal Commerce as a powerful event booking system. Any entity can be an 'event' and a single booking can contain any number of tickets.


How to remove language indicator in content region?

Home » Administration » Configuration » Regional and language »
  Multilingual settings

then

go to the "Node Options" tab

check

  Hide content translation links


entity_metadata_wrapper langcode always prints default language

Try this

print $wrap->language('zh-hans')->field_main_subtitle->value()


How to restrict access to private files to members of an organic group?

OG provides no access control on attached files.  I ran into the same situation and came up with two options.

The file depot module integrates nicely with OG and does prevent users who are not members of a group from accessing files that are attached to a group.

  The filedepot module is full featured Document Management module that has a google docs like feel. It fulfills the need for an integrated file management module supporting role and user based security. Documents can be saved outside the Drupal public directory to protect documents for safe access and distribution.

Another option is writing a custom module that implements hook_file_download().  In that module you would have to get the node id of the file attachment then use that to determine what group the node belongs too then from there determine if the logged in user is a member of the group.  If they are not a member of the group the module would return -1 which would give them access denied if they try to directly download the file via url.


Extracting field values (of certain entity type and bundle) from form/form_state

All the field values are in $form_state['values']. See: drupal_form_submit.

You might also be interested in using hook_form_BASE_FORM_ID_alter instead of hook_form_alter to target a particular content type. Your function would look like: 'mymodule_form_' . $form_id . '_alter'.

Or at least an:

if ($form_id == 'your_content_type') { // add new submit handler }

in hook_form_alter.

Also use LANGUAGE_NONE, without quotes, instead of 'und' ie $some->var[LANGUAGE_NONE]['value'];

Also for future reference:
Install the Devel module, use dpm($form_state,'$form_state');

When you use dpm you get nice dumps of variables that look like:
http://goo.gl/qIf6p


Aggregation with count that includes empty field values

I've not found a way to do this thing, but if any other needs something similar, i end up using Computed Field to handle this case, so i can store the actual field value normally, or another text (in my case 'Not filled').

Using this computed field instead of the actual field makes everything works...

But i'm open to change this thing if there's a better way to do this, as this sound a bit hacky...


jQuery Update has some problems with v1.8.7 currently (related to the version of jQuery UI included); downgrading to v1.7 should fix the problem.

See these issues on D.o for more information:

Suddenly stopped working - TypeError: c.curCSS is not a function
Update jQuery UI to 1.8.24

The reason your View isn't working is simply that the Javascript error is preventing the relevant events from being attached to the elements. So when you click a link, instead of Views loading the JSON via AJAX and processing it, you're instead forwarded to the JSON page itself.


Restoring accidentally deleted content type

If a content type has been deleted, possibly all content of that type have lost their type setting, and so even if the content type is recreated, they might not be recognized as belonging to that type.

This should go without saying, but clearly that's not the case. Take a backup, before you happen to make things even worse.

You'll need to manually update the type column of the node table to the machine name of the content type.


How to set the profile picture validation in profile 2 module in drupal 7?

Just create the template of your registration page and need not print the upload image field over there and when user will register your self print that field to the edit profile form page from where user can upload the picture ..

Thanks


Check if mod_rewrite is enabled (if you are using Apache as your web server).
Add .htaccess file to the root of Drupal installation. Here is a link to documentation.


Unfortunatelly for Drupal 8 @No Sssweat's solution of creating 3 seperate views (blocks) is the ONLY possible solution using views at the moment.  Then you can put them in region of your liking and with css can display them one next to the other (inline).

When Taxonomy vocabulary data not available as views fields is not an issue anymore you will be able to do it with just 1 view and grouping terms by vocabulary name.

Otherwise another solution would be to make your own custom module that gathers and displays the vocabulary terms.


Current password required to change password for self-registered users. No password was ever set

I have solved my issue by re-installing the login one time module and clicking the Ignore the current password field checkbox.

This hides the Current password field for the one time login link, and everytime after requires the user to provide a Current password if they want to change their email, password ect.

The problem is that this website will still ask for a current password for validation links if I uninstall the Login-one-time module, which makes no sense to me.


Display a list of a user's Organic Groups

You can use og_get_groups_by_user() for that.

  Get the group IDs of all the groups a user is an approved member of.

The API linked to above might be for OG 1.x, it's slightly different for OG 2.x.

 function og_get_groups_by_user($account = NULL, $group_type = NULL) {
 ...

For instance:

 global $user;
 $user_groups = og_get_groups_by_user($user, 'node');

The above example is not really great as $account defaults to current user and without $group_type you get all types of groups, not just node groups, but you get the general idea.


How can my module add xml sitemap entries?

The base function you call is xmlsitemap_link_save.

I am unaware of any docs on how to use this, but nodes get added to the sitemap via xmlsitemap_node_nodeapi which in turn calls xmlsitemap_node_create_link.  The code for that should provide some guidance on how to build $link.


In D7 Terms are "entities", which means you can set an image field right on them, just like you could have with CCK in Drupal 6.

Just go to manage fields on whatever vocabulary you want, and you can add the image field.


How to change the date of rewarded User Points?

Have a look at the User Points Contributed modules as a possible alternative. I.e. its submodule userpoints_retroactive. Excerpt from that project page:

  Award users points for their nodes, comments and votes that they have created so far, before userpoints was enabled on the site.

Comment nr 9 of issue nr 1187616 contains a patch with these enhancements:

Ported the module to Drupal 7.
Added support for retroactive revisions.
Made provisions to store the timestamp of original node and revision.

So instead of trying to change the dates of the User Points transactions, I'd delete the transactions you already have, and try to recreate these transactions using this patch.

PS: there is also Berdir's Api documentation about this submodule ... (maybe that helps somehow).


How to use ajax_command_invoke() with an argument that's a JavaScript object?

I solved this by creating a little jQuery Plugin that calls droppable(), and using ajax_command_invoke() to call my plugin.

In the PHP code that builds the page, I added:

drupal_add_js(drupal_get_path('module', 'my_module') . '/my_module.js');

In my_module.js, I added:

jQuery.fn.my_module_make_droppable = function() {
  jQuery(this).droppable({
    drop: function(event, ui) {
      jQuery(this).addClass( "ui-state-highlight" );
    }
  });
}

And my AJAX callback is now:

$commands = array();
$commands[] = ajax_command_invoke('.elements-to-make-droppable', 'my_module_make_droppable');
return array('#type' => 'ajax', '#commands' => $commands);


Advice on latest drupal security advisory having followed most of the instructions do I rebuild the server?

You have a couple of questions here so I'll answer the one that I can. File permissions.

The short answer is it depends on your setup as to what the best permissions are.

It depends on your system's users and groups and what account runs the web server process.

There is a lot of more detailed information at Securing file permissions and ownership.

I will give one specific though:

Something to consider aside from the security of your website is the security of your server.

If all your files have to be edited by root does that possibly mean you are regularly using the root account or sudo to do things?
If so that is bad for server security. You shouldn't really need to be root to edit website files like that.

Instead of using root maybe use a non-root account with a strong password.

Remember, root is no stronger than any other user in terms of what password they are required to log in with, but has infinitely more power once they're in.


How to exclude certain variable from the Feature code?

The hook_features_export_alter would allow you to alter the final array of Component names to be exported, just prior to the rendering of defaults.

This allows feature modules a final say in whether or not certain Components are exported.

However the Components' actual data cannot be altered by this hook, so I'm not sure if that actually helps.

Example:

function hook_features_export_alter(&$export, $module_name) {
  // Example: do not allow the page content type to be exported, ever.
  if (!empty($export['features']['node']['page'])) {
    unset($export['features']['node']['page']);
  }
}


Migration taking increasingly long periods of time

What's the total number of nodes you're importing? I've hit this issue before using the D2D Migration module. I've found that D2D starts to slow down on consecutive batches when I'm importing in more than ~5K nodes. In scenarios where I've needed to import 10K-100K nodes, batches eventually slow down to where nothing is ever imported.

Using XHProf & XDebug, I traced down the issue to database objects consuming tons of memory & CPU to the point of stopping PHP execution. I've never been able solve the issue for importing over 10K nodes using D2D. Searches all over the internet have produced nothing. In many instances I've had to rely on custom PHP import code as since I could not use D2D.


how to get the value from a field in hook_node_load($nodes, types)

The $nodes variable is an array of node objects. You either need to loop through the array and extract the field values, or get the first item off the array and use that. For example:

foreach ($nodes as $node) {
  if ($node->type == 'content_type') {
    $field_items = field_get_items('node', $node, 'field_tt_status');
    $status = $field_items[0]['value'];
  }
}


How do I use sendmail on Debian/Ubuntu to send emails without SMTP or other modules?

OK, thanks to Clive I stopped assuming things and checked the php.ini file. Sure enough the sendmail_path option just had "/usr/sbin/sendmail".

I've updated php.ini with "sendmail_path = /usr/sbin/sendmail -t -i" and it's working beautifully.

Doh!


Why does all links of homepage redirects me to Xampp homepage ( Took backup from Godaddy )

I tried copying the .htaccess file available inside the Drupal package and pasted into my htdocs drupal folder.
Works like charm till yet.


hook_form_FORM_ID_alter being called twice (even before submit)

It has to do with the fact that Drupal redirects after the form submit. So after a form submit you will make 2 requests: the form submit and the redirect. Hence the 2 messages in your hook_form_alter().

You can disable this redirect by calling $form_state->disableRedirect() in your form submit handler. By disabling the redirect the form values will be preserved in the form. The redirect is in place to 'clean' the form inputs after submission.


Custom Line Item Loses commerce_unit_price and commerce_total

The implementation of hook_commerce_line_item_type_info() fixes this issue. Each custom line_item needs to be created via this hook. This will add the two fields commerce_unit_price and commerce_total to the line_item.


We got the same errors here.

After some time we recognized that our database-import (cloning production db to local dev machine) went wrong and the database wasn't populated properly. After fixing the db the errors went away...

So - my hint: check your database structure and data.

BTW: There is a similar question - but with an memcached in the drupal setup


Installed Views Module but It did not appeared in Structure

You have to enable Views UI in order for it to show up under Admin -> Structure.


How to display a custom render element after an existing one?

Are you sure that code is correct?

$build['sessions'] = array(
  [
    "#markup" => "
Sessies
",
    "content" => array(
      Drupal::entityManager()->getViewBuilder('node')->viewMultiple($nodes, 'speaker_sessions')
    )
  ]
);

It appears you are creating 2 arrays (array() and []). The given example hook_ENTITY_TYPE_view() looks like this:

$build['mymodule_addition'] = array(
  '#markup' => mymodule_addition($entity),
  '#theme' => 'mymodule_my_additional_field',
);

The problem you are likely having is because of the nested array. If you apply a weight to the inner array, it will sink to the bottom of the outer array. You however still have no control over the position of the outer array. So either use a single array and add the weight there, or use the double array as it is, but apply the weight to the outer array.

But that conflicts a bit with your question because this is not a view mode, it is just an extra render element.


How to re-enable content notifications for Notify?

Reading your comment on my question above, I guess you're using Actions & Triggers in Drupal 6.

To see which actions you have defined or to define new actions, go to Administer > Site Building > Actions. There e.g. you can define an action for sending an email. From your question I think you already have done that (in the past).

To assign this action to an event, you have to go to Administer > Site Building > Triggers. There you can choose (under Content) to assign an action to an event, such as published or updated content.


Data about the node needed to be supplied as a parameter to the replace method.
It worked once I used

$node = \Drupal::routeMatch()->getParameter('node');
$vars['label'] = $token->replace($vars['label'],['node' => $node]);


How to update route cache when saving an entity?

Turns out I just had to chain it to the AccessResult like so:

AccessResult::allowed()->addCacheableDependency($requested_profile);

Same for forbidden(). Now the 'View' tab is visible appropriately.


The first thing I'd probably do is to change the url option of $.ajax to something like:

$.ajax({
  // your code goes here
  url: Drupal.settings.basePath + 'addstuff/ajax',
  // more of your code goes here
});

So, what could be happening (assuming of course, that you have clean URLs enabled on both sites) is that when you are on a page on your site with the Drupal path, say, node/add and click on your link, the AJAX request to addstuff/ajax without the leading slash (base path) goes to node/addaddstuff/ajax which will return HTML and not JSON as expected. Hence, jQuery throws a parseerror and Drupal calls its error handler. You can check this by inspecting the XHR requests being sent out from the Network tab of your browser's developer console.

However, this doesn't explain how your code works as expected on one site but not the other.


How do I set a condition to only show a block to members of a group?

Programmatically you can use Group::getMember() to determine if an account is a member of a group.
if ($group->getMember(\Drupal::currentUser())) {
  // the current user is a member of the group.
}

Note that Group::getMember() returns a GroupMembership entity.
You could then create a condition plugin, using the above methodology to determine if the current user is a member of the group. I've created a tutorial on how to use the Conditions API to create conditions plugins, using this example of a condition where a member is a member of the group: https://www.jaypan.com/tutorial/custom-block-visibility-plugins-and-condition-plugin-api


How to programmatically remove a field from a node?

field_delete_field($field_name) will mark the $field_name for deletion on next cron run.

You could use field_purge_batch to do the deletion, if you don't want to do it on cron run.

EDIT: field_delete_field() should be used when you need to delete the field from other bundles as well. If you only wish to delete the field from a particular bundle you should use field_delete_instance() as mentioned by @Clive.


link to node field on another content type

You should be able to accomplish this using the Linkit module which has access to managed files.


go the omega theme folder omega\starterkits select : default or extended folder and copy in site/all/themes .
change folder name default or extended to your subtheme name for example "alex".

go to your theme folder finde the extended.starterkit.inc or default.starterkit.inc and change to your theme name in my case is: alex.info

open alex.info and change name and description of your subtheme.


I would do the following:
    <pre>
    <?php print_r ($row); ?>
    </pre>
This will give you the full tree of the $row


The most common problem that could cause this is a broken mail setup.

Please the if you can sent an email from the server's cli to aegir@site.dev.local


Finally I solved applying this patch to views in order to get GROUP_CONCAT as an aggregate function in views UI and uninstalled views_merge_rows.
I think this is a better solution from a sql query performance point of view: views_merge_rows simply changes how data appear. Probably I was wrong in configuring something in it but I won't investigate any more.

Thanx all for reading...  ;-)


Instead of dropdowns, you could use checkboxes and line item fields using Commerce custom products module.

All fields are supported as customer-facing line item fields, except some entity reference fields that use views to display their options. Note, the only limitation here would be that your fields would need to be able to react to the specific product.

Customizable products are like content types and define fields per bundle. So you would need a bundle per unique set of requirements. There is no limit, but it would probably be easier to model the "selection criteria" using fields on the products and then create a hook_form_alter() that would change the options available to select.

UPDATE: Code Example

Assumption 1: You've created a custom line item bundle

Assumption 2: You've created two fields. The first for the line item options (this would include all possibilities) and the second would be for the product (this would include any possibilities that match what that kind of product should have, doesn't need to be a complete list, but it would need to be the same ids/values of the first field).

Assumption 3: The workflow would look like this:

  select the soaps you would want to show PER product

Now, on the product display you would see this:

<?php
function MODULE_form_alter(&$form, &$form_state, $form_id) {
  if (strpos($form_id, 'commerce_cart_add_to_cart_form_') === 0) {
    $product = $form_state['default_product'];
    $show_these = $product->field_include_these_soaps['und'];
    $all_soap_options = $form['line_item_fields']['field_soaps']['und']['#options'];
    $only_show = array();
    foreach ($show_these as $key => $value) {
      $real_key = $value['value'];
      $only_show[$real_key] = $all_soap_options[$real_key];
    }
    $form['line_item_fields']['field_soaps']['und']['#options'] = $only_show;
  }
}
?>


Related node views - some elements with date field, some without. How to include elements with no date in results?

Problem is in the very SQL. No date field in node means null value in result set. Any logical operation with null ends up returning null, see manual. And null is a logical false for conditions. So, each time you test a date to see what are OK, MySQL excludes them - lack of date is not a date in acceptable range.

If views would support negative filtering (exclude matching), it would be just as you want it. But views support only positive filtering (include only matching).

Enough of diagnosis, time for solution!
On the block's header Filter criteria you have a dropdown with add seelcted. Drop it down and use And / Or, rearrange. Make your filters OR, and after date limit add some other filter, one that will return true for no-end-date nodes. Here comes the tricky part - you can select the same field multiple times, but you cannot use null in place of date. If nodes without a date are simply of another content type, you are good. If they are of the same type, you have a problem - I'll add solution for that particular case if I'll find it.


Handling dynamic URLs through my custom module

Firstly, you should not define a callback as ['/test-1'], instead just use ['test-1'], without the slash - '/'.
Check here - http://api.drupal.org/api/drupal/developer!hooks!core.php/function/hook_menu/6

If you want to create 100 menus, go ahead, this is the way you can do this.
If just the path is changing and nothing else, I would recommend to create an array, and then loop it, defining the value of the array item in the menu-path.
something like this -

$arr = array('test-1', 'test-2', 'test-3', 'test-4', 'test-5');
foreach ($arr as $a) {
  $items[$a] = array(
  'title' => 'Test',
  'page callback' => 'drupal_get_form',
  'page arguments' => array('mymodule_test'),
  'access arguments' => array('administer mymodule'),
  'type' => MENU_NORMAL_ITEM,
  );
}

This will be less code and quick.


How can i fetch the value from database in a simple module?

Something like this should work:

/**
 * Implements hook_block_view
 */
function MY_MODULE_block_view($delta = '') {

  if (($node = menu_get_object()) && ($node->type == 'product')) {
    $query = db_select('uc_auction_bids', 'bids');
    $query->fields('bids');
    $query->condition('nid', $node->nid);
    $result = $query->execute()->fetchAllAssoc('bid');

    // Debug
    drupal_set_message('<pre>'.print_r($result,1).'</pre>');

    $content = ''; // Format records here...

    return array(
      'subject' => t('Bids'),
      'content' => $content
    );
  }

}


Update warning: "Some of the pending updates cannot be applied because their dependencies were not met." Followed by "No pending updates."

Just in case someone else finds this ... I added a watchdog line to the function update_script_selection_form($form, &$form_state) in update.php.

foreach ($updates as $module => $update) {
  if (!isset($update['start'])) {
    $form['start'][$module] = array(
      '#type' => 'item',
      '#title' => $module . ' module',
      '#markup'  => $update['warning'],
      '#prefix' => '
',
      '#suffix' => '
',
    );
    watchdog('update','NO START: '.$module);
    $incompatible_updates_exist = TRUE;

    ...

It was XML sitemap causing the problems on a D6->D7 upgrade, and I ended up having to delete its tables manually before it would uninstall.


If you want to pass data into the module, then you don't want to do it at the theme level. The theme layer should be all about output, not data. Try solving it with a fielded entity, templating through a text field with full HTML filter and  adding CSS through another field. Images could then be added with a file field.


Disclaimer - Use this method at your own risk, it has security implications if you don't set up and test it properly :)

A quick and dirty way to override that functionality would be to implement hook_module_implements_alter(), remove the image module's implementation of hook_file_download(), and then implement your own version which has the desired logic. e.g.

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'file_download') {
    unset($implementations['image']);
  }
}

function MYMODULE_file_download($uri) {
  // Copy the code from image_file_download() and alter as required.
}


Yes, arguments can be passed when calling the theme function:

$tpl_data = array(
    'data1' => $data1,
    'data2' => $data2,
);

return theme('my_theme', $tpl_data);

Then in the template $data1 and $data2 will be available.

To add a variable passed here to the default drupal class variable in the template we could add the line:

$class .= " $data1";

before the $class variable is printed.

However I think it's questionable  whether or not this method is preferable to your original.


I had the same problem, so please try this:

$url_object = \Drupal::service('path.validator')->getUrlIfValid($path);
$url_object->setAbsolute();
$url = $url_object->toString();


Custom Styles Applying to page.html.twig but not html--front.html.twig

The code in html--front.html.twig is identical to the code in page.html.twig

That's your problem - those are two different templates, it doesn't make sense for them to have the same content.

html.html.twig contains (or more accurately, renders) page.html.twig, plus the <head> tags and all that lives within, the footer of the document, and so on. If you copied page.html into html.html, that explains why you don't see styles any more - your <head> is gone.

It's perfectly valid to have html--front.html.twig and page--front.html.twig, or some other combination, but the html template needs to contain the outer part of the document, and the page template needs to contain the inner part.


Set all boolean certain fields to 0 if 1 with rules

To clarify, you have created a new flag using the Flag module and attached it to a taxonomy bundle (either terms or vocabularies) and want to reset these flags.

You can do this directly in your database with a couple commands. First, you need the Flag ID of your flag which is in the 'flags' table:

mysql> desc flags;
+--------------+----------------------+------+-----+---------+----------------+
| Field        | Type                 | Null | Key | Default | Extra          |
+--------------+----------------------+------+-----+---------+----------------+
| fid          | smallint(5) unsigned | NO   | PRI | NULL    | auto_increment |
| content_type | varchar(32)          | NO   |     |         |                |
| name         | varchar(128)         | YES  | UNI |         |                |
| title        | varchar(255)         | YES  |     |         |                |
| global       | tinyint(4)           | YES  |     | 0       |                |
| options      | text                 | YES  |     | NULL    |                |
+--------------+----------------------+------+-----+---------+----------------+

You can find this by selecting the fid, and name from flags:

mysql> select fid, name from flags;
+-----+---------------+
| fid | name          |
+-----+---------------+
|   1 | bookmarks     |
|   3 | taxonomy_flag |
+-----+---------------+

In my development server, the taxonomy_flag id is 3. Now take a look at the flag_content table where all the flag content data is stored:

mysql> desc flag_content;
+--------------+----------------------+------+-----+---------+----------------+
| Field        | Type                 | Null | Key | Default | Extra          |
+--------------+----------------------+------+-----+---------+----------------+
| fcid         | int(10) unsigned     | NO   | PRI | NULL    | auto_increment |
| fid          | smallint(5) unsigned | NO   | MUL | 0       |                |
| content_type | varchar(128)         | NO   | MUL |         |                |
| content_id   | int(10) unsigned     | NO   | MUL | 0       |                |
| uid          | int(10) unsigned     | NO   |     | 0       |                |
| sid          | int(10) unsigned     | NO   |     | 0       |                |
| timestamp    | int(10) unsigned     | NO   |     | 0       |                |
+--------------+----------------------+------+-----+---------+----------------+

What you want to do to reset all the values for your target flag is delete all entries from the flag_content table, so in my example above that would be

delete from flag_content where fid=3;


How do I separately get label and field?

To access separately labels and values for fields in twig template (example in node twig template: node.html.twig) I propose to loop all the node variable.

My example:
Instead of print all content with this line {{ content }} loop the content object

    {% for item in node %}
        {# Print the label of the field #}
        {{ item.fieldDefinition.label }}

        {# Print the value of a field text/simple field #}
        {{ item.fieldDefinition.value }}

        {# Print the value of a field reference  #}
        {{ item.value[0]['target_id'] }}
    {% endfor %}

Other way is to use this module: https://www.drupal.org/project/twig_field_value


This question seems somewhat off-topic as you don't know what this thing is and how to generally change that, independent from Drupal, and I'd recommend to find that out first.

But to take a shortcut from here: that's the so called meta title. And you'll be able to customize it pretty heavily by using Metatag.

  The Metatag module allows you to automatically provide structured
  metadata, aka "meta tags", about a website. In the context of search
  engine optimization, when people refer to meta tags they are usually
  referring to the meta description tag and the meta keywords tag that
  may help improve the rankings and display of a site in search engine
  results. In addition, the module provides support for meta tags (Open
  Graph Protocol from Facebook, Twitter Cards from Twitter) that allow
  control of how content appears when shared on social networks.


What you're seeing is how Drupal represents fields in a form. It breaks down like this:

The children of the outer array, $form['field_back']['und'] ('und' for 'undefined'), are the different languages the field has been translated into. In Drupal, you are recommended to use LANGUAGE_NONE for 'und' in code.
The children inside each language array, e.g. $form['field_feedback']['und'][0], represent the different entries for the field. For example, if a field has unlimited cardinality, and there are several entries for that field, they will show as $form['field_feedback']['und'][0], $form['field_feedback']['und'][1], etc.
Finally you have the form input element(s), for the field values themselves, e.g. $form['field_feedback']['und'][0]['value']. In this case the column name is value, for a node reference field type it would be nid, and so on. If a field has multiple data columns associated with it you'll see more children as well. These are represented by a text field/select box/special widget, and will ultimately provide the value for the field.

The fact that titles have been added to the various elements throughout the hierarchy is incidental to be honest. Whether or not those titles are displayed on the form is down to the particular settings of the render array in which each #title is contained.

To change the title on the actual form widget, you only need to worry about the form element at the very bottom of the array: i.e. the actual input elements ($form['field_feedback']['und'][0]['value'], etc.).

It's probably worth noting that the element/widget used for a particular field may be quite complex. If you don't already have it, you should install the Devel module and use the dpm() function to inspect the $form array; that will show you exactly where in the array the elements you're trying to target are.


I think you are asking about hook_menu().

what you need is to create an item which has a base of boats, and takes an argument.

function mymodule_menu() {
  $items = array();
  $items['boats/%'] = array(
    'page callback' => 'mymodule_boats',
    'page arguments' => array(1),
  );
  return $items;
}


Display suite fields visibility restriction

Yes. You can create a custom view mode with DS, add or remove fields as you wish, configure that view mode to use a DS layout, then access the view mode through a URL.

The structure looks like this for the "full" view mode: node/x?v=full.

You need to enable a DS Extra setting called "View mode per node" at admin/structure/ds/list/extras


Assuming you are working with the default Article content type of Drupal 7.x

You should add something similar to this in your NO RESULT BEHAVIOUR of your IMAGE field in your VIEWS


Fatal error: Call to undefined function system_run_automated_cron()

For some reason it hasn't defined system_run_automated_cron() in the core system module. It's just a matter of figuring out why. A couple of things to check are:

Since you moved the DB over, did all the tables get created correctly? Check for the system table for a row entry with the name column set to "system". Is the status column set to 1?
Does modules/system/system.module exist and is executable by the webserver?


You need to setup a private file system in settings.php:

/**
 * Private file path:
 *
 * A local file system path where private files will be stored. This directory
 * must be absolute, outside of the Drupal installation directory and not
 * accessible over the web.
 *
 * Note: Caches need to be cleared when this value is changed to make the
 * private:// stream wrapper available to the system.
 *
 * See https://www.drupal.org/documentation/modules/file for more information
 * about securing private files.
 */
# $settings['file_private_path'] = '';

Files stored in the private file system will be served by Drupal and you can control which users are allowed to access the files.


How to manage multisite themes from master Drupal installation

The README.txt file in Drupal's /themes directory states:

  …the sites/your_site_name/themes directory
  pattern may be used to restrict themes to a specific site instance.

For instance, you might have:

- sites/all/themes/m1
- sites/childsite1.com/themes/c1
- sites/childsite2.com/themes/c2
- sites/childsite3.com/themes/c3


If not Views Bulk Operations as mentioned in the comment above by arpitr there seems to be one function from the core users module which appears to be of the purpose for the same. The User module's hook_user_operations for block operation namely user_user_operations_block would be it to answer your query and should provide you a drupal code way of doing it.

function user_user_operations_block($accounts) {
  foreach ($accounts as $uid) {
    $account = user_load(array('uid' => (int) $uid));
    // Skip blocking user if they are already blocked.
    if ($account !== FALSE && $account->status == 1) {
      user_save($account, array('status' => 0));
    }
  }
}

Essentially it loads the user account and makes call to user_save with the status as 0. If your implementation is to block users with custom code based on a specific logic, you could do the same or perhaps consider invoking the user module's hook_user_operations for block operation with the desired input though I haven't done something similar. Doing so would prevent you writing your own update query. Hope that helps.


A menu link that points to specfic place on a page (I can't use anchors)

I know it's been a while, but I found this forum post and thought it might help you:

http://forums.adobe.com/thread/13098


Strange behavior with flexslider: Uncaught TypeError: $(...).flexslider is not a function

Try this: Install jQuery Update module. Seems like your jQuery version is out of date.


How to make changes in HTML code and make them show up on site

Look into using the Features module. This way, you can convert any configurations that are stored in the database to code, push them up to the repository, and then pull and revert all the features on your test and production site. You can add template work as a custom feature as well. You should stray away from editing code in Drupal and lean toward creating custom themes, modules and features. I would be no where without this module.


Calling theme_hook_suggestions inside template.php

theme_hook_suggestions is not for function suggestion, it is for template suggestion.

In your case:

$variables['theme_hook_suggestions'][] = 'block_system_main_front';

Drupal will try to load the file:

your_theme/templates/block-system-main-front.tpl.php


I solved the issue by adding a canonical link via hook_html_head_alter().


Possible, yes.  Recommended, no.  I do a lot of importing from outside sources, and would never entertain using direct SQL INSERT statements.

I would export your existing database in another format, and pursue one of standard approaches.

The easiest is probably Feeds.  In your case, I would export as CSV, and then use the CVS imported built into feeds.  Based on your description, it sounds like you have a one-to-one mapping, and the CSV importer is good for this.

The Migrate module can also handle moving data from one source into Drupal.

A more robust solution would be to create a custom importer, build up a $node, and then use node_save.  There are a lot of nuances with this, and this is not a good approach unless you are familiar with the Drupal API already.


Taxonomy shows term ID not term name in Facet API

in

  admin/config/search/facets/your_facet_name/edit

you must select :

  List item label
 Translate entity label


Find the solution below:

(function($) {
  Drupal.behaviors.events = {
    attach: function(context, settings) {
      $('#views-exposed-form-recherche-artiste-page', context).ajaxSuccess(function(){
         $('h2').text('filters');
      });
    }
  };
})(jQuery);


Attributes are not changing in the placed order

This is a known issue with page level caching system for anonymous users in Drupal. Please subscribe to the open issue on the authcache issue tracker, then you will be notified as soon as this is fixed. There is also a report in the Drupal Commerce Queue


Does anyone know of a module like "Artsy Editor" for Drupal?

There's no module for Artsy Editor.
But if you mean inline editor, you can use Edit for Drupal 7 and 8 - In-place editing for fields on any entity. Including WYSIWYG editing powered by CKEditor or Aloha.
"Edit" is part of Spark - Drupal distribution which aims to be "the Pressflow of Drupal authoring experience


How to access database table with drupal 7

If you have an autoincrement value for the primary key on the table you are inserting, then the execute() function will return you this increment value. So just check what it is returning.
But do make sure the value is defined as an autoincrement (defined as serial in hook_schema) because otherwise the returned value should not be used as it is undefined.

$nid = db_insert('node')
  ->fields(array(
    'title' => 'This is only a test.',
    'uid' => 1,
    'created' => time(),
  ))
  ->execute();
// This will ouput the $nid value to Drupal log.
 watchdog('yourmodule', "The value for nid is $nid .");


Some links in admin not working correctly

I finally got an error message to work with (TypeError: this.jqObject.data(...) is undefined), which led me to this solution:  https://drupal.org/comment/8677587#comment-8677587:

Hi guys, I am pretty new to Drupal and programming in general, so pleas bear with me... I got the data selector working by configuring the jQuery_update module:
Default JQuery Version: 1.7
Alternate JQuery Version: 1.7
JQuery Compression Level: Development (I doubt this should make any differences)
JQuery and JQuery UI CDN : JQuery


How to change the currency symbol according to language in site?

Have a look at the Currency module, here is a quote about it (from its project page):

  ... provides your website with currency conversion, currency information & metadata, and amount/price display functionality.

This module facilitates Localized price display. Here is an excerpt from that link also:

  ... displays prices/amounts based on users' locales, so they are formatted in a way that is familiar to them. The different formats can be configured at Home » Administration » Configuration » Regional and language » Currency localization. Locales consist of a language and a country, and formatting patterns are configured per locale.


Editing the default layout for a content type in Panopoly

You're looking for the panels (node_view) page. You should be able to find it at admin/structure/pages and then look for node_view.  Edit that page and add a new variant for your content type.


How do I upload a PDF for users to download?

It's easy, in admin/structure/types/manage/article/fields make file field like so:

All other stuff is logical:

Don't forget to put PDF as an allowed extensions:


Taxonomy terms from multiple vocabs on a single line

This change in my style.css did the trick :

.node .taxonomy,
.node .field-type-taxonomy-term-reference {
  font-size: 0.8em;
  line-height: 100%;
  display: inline;
  /* padding-left: 1.5em; */
}


Views and joining content types on specific field in Drupal 7

In views 3 you have the relationships which manage JOINS between tables.
First you add your relation with the table and then in the next screen you can select Require this relationship.

If you check this checkbox, a LEFT JOIN will be made between the tables, if you uncheck it, it will generate a LEFT OUTER JOIN.


Are there any hooks that get called before modules are loaded?

I don't recommend using hook_init() as it doesn't run on cached pages. Try using hook_boot(). As per the documentation it runs at the beginning of the page request when Drupal is still in the bootstrap. Hope this helps!


How do I filter a menu to only show menu items translated into current language?

I managed to hide non translated menu items with the following code:

use Drupal\Core\Menu\MenuLinkInterface;
use Drupal\menu_link_content\Plugin\Menu\MenuLinkContent;

/**
* Implements hook_preprocess_menu().
*/
function MY_MODULE_preprocess_menu(&$variables) {
  if ($variables['menu_name'] == 'main') {
   $language = Drupal::languageManager()->getCurrentLanguage()->getId();

    foreach ($variables['items'] as $key => &$item) {
      $menuLinkEntity = MY_MODULE_load_link_entity_by_link($item['original_link']);

      if ($menuLinkEntity != NULL) {
        $languages = $menuLinkEntity->getTranslationLanguages();
        // Remove links which is not translated to current language.
        if (!array_key_exists($language, $languages)) {
          unset($variables['items'][$key]);
        }
      }
    }
  }
}

function MY_MODULE_load_link_entity_by_link(MenuLinkInterface $menuLinkContentPlugin) {
  $entity = NULL;

  if ($menuLinkContentPlugin instanceof MenuLinkContent) {
    list($entity_type, $uuid) = explode(':', $menuLinkContentPlugin->getPluginId(), 2);
    $entity = \Drupal::entityManager()->loadEntityByUuid($entity_type, $uuid);
  }
  return $entity;
}

There is probably a better way but this worked for me.
Got the inspiration from here: http://www.agoradesign.at/blog/add-custom-menu-item-attributes-drupal-8


The array keys available in $context are listed in Batch operations:

  The following keys are provided:

  'results' (read/write): The array of results gathered so far by the batch processing, for the current operation to append its own.
  'message' (write): A text message displayed in the progress page.

  The following keys allow for multi-step operations:

  'sandbox' (read/write): An array that can be freely used to store persistent data between iterations. It is recommended to use this instead of $_SESSION, which is unsafe if the user continues browsing in a separate window while the batch is processing.
  'finished' (write): A float number between 0 and 1 informing the processing engine of the completion level for the operation.
  1 (or no value explicitly set) means the operation is finished and the batch processing can continue to the next operation.


Views format: faster fields or rendered entity?

If you are able to cache the views output, you should not need to think about that problem. If it is not cachable:

I would say rendered entity will cause more overhead due to rendering each field of the content you selected while with fields you could limit it to the needed fields. If rendered entity and fields equal, I would go for rendered entity with display suite.

For actual performance benchmarking try using apache's benchmarking tool for both solutions.

ab -n100 -c1 http://domain.tld/path/to/view

remember to disable caches while running the tests.


You can never import to created view. View is to create, manage, and display lists of content. So first you have to import the data from excel sheet to the content type which you are using into your view as a content type filter.

To import the data, install Feeds module.

  Import or aggregate data as nodes, users, taxonomy terms or simple
  database records.


Adding template to garland, preprocess page doesn't work

If processfront is an alias for a specific node, let's say 228, then its system path is really node/228 and arg(0) will be node.  If you've set your system up so that this node is your front page, you can just use page-front.tpl.php and drupal will take care of it automagically.  Otherwise, you can use drupal_get_path_alias() and check against that.


Struggling with View Slider Image Rotation

The basic setup for the slider depends on two factors:

1.) A collections of nodes of a particular type, in your case image_slider.

2.) A view that manages the slideshow outputting it as either as a page, block or both.

So, initially go to create (for example) 3 nodes, each containing an image, as the content-type image_slider.

Then go ahead and access your view under admin/structure/views and ensure that:

The format (under Format) is set to Slideshow
You are "showing" (Show:) Fields (under Format)
That you have selected your image field to be called (under Fields).
That your filter criteria has the content type set to image_slider
Finally, that under "Pager" (in the second column) you have set the pager to display "All Items" - you can change this later to limit the output but for now this will ensure that all node-fields, which meet the previously mentioned conditions, will be output.

Once all of these conditions are met, save the view and it should already display the slider in action at the bottom of the page as part of the preview. If everything went smooth, you can now access either your view-page output or set the block under blocks to display your slideshow throughout your website.


The node form will not submit,if the word 'exit' is put in the title field

No, Drupal doesn't have any word blacklists.

That logic must be caused by a custom or contributed module that you have installed (or even a theme I suppose). Try methodically disabling modules/themes until you find the culprit.

Starting with modules that provide text filters or alter the content body in some way would be the obvious places to start.


The "cd" command in your commandfile is working correctly; however, it is a standard behavior for *nix (and Windows) that environment variables, such as the current working directory variable set by the 'cd' command apply only to the process that they are set in.  Drush runs in a separate process from the shell that you launch it from, so your current working directory will revert to its original value when Drush terminates.  (It actually never changed, since each process has its own environment.)

Instead of using a Drush alias (site alias or shell alias), what you might actually prefer is a bash alias.  For example:

$ alias go='cd /dir/to/move/my/shell'
$ go
$ pwd
/dir/to/move/my/shell

There's a lot more you can do here if you define site aliases for your site, and source the example bashrc file that Drush provides; see the Drush README file, and the examples folder.

If you want to write fancy php code change your working directory, you need to put only the code that calculates the destination path, and then call 'cd' from a shell alais.  For example (from bash):

$ alias go='cd $(drush dd @mysite)'
$ go
$ pwd
/path/to/drupal/root/of/mysite

This one liner will also do the trick:

$ cd `drush @mysite dd`

zsh aliases have the same syntax as bash aliases:

http://zsh.sourceforge.net/Intro/intro_8.html

It also looks like process substitution has the same syntax in zsh as well:

http://zsh.sourceforge.net/Intro/intro_7.html#SEC7

However, I haven't tried any of this in zsh.


How to insert data into node and other tables at the same time?

Why you are using custom code to store the records in the node table. Are you calling any API service or you creating form yourself?

If you have created content type, then just go with drupal way and call custom submit function to store products and price values in a separate table by using db_write_record() or db_insert() function to insert the record in the database.

Just go through the below link

https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_write_record/7
https://www.drupal.org/node/310079