website doesn't load I had a fully working Drupal site and had some problems with uploading files on a specific page.  So I started looking closely at the code and noticed some oddities (basically a lot of random characters).  I removed the code and everything seemed to be fine.  The code had to do with the images on the page.  Then all of a sudden I started receiving a "page cannot be displayed" error, and was not able to view the site anymore.

I had someone else look at the server and they were able to connect just fine.  To be on the safe side, they rebuilt the page.  I tried again, and still couldn't see the website.

I then tried to attempt the connection through another network I manage via VPN.  Coming at it from the other network, the page loads.  I've tried Firefox, Chrome, Safari, all with the same result.  I tried clearing the cache, reset settings, delete and reinstall.  I've restarted my router.  I'm out of ideas.  This has been super frustrating.  Thanks for any help.

Update:  I talked to the person hosting this and they mentioned they run something called Liquid Web.  I guess it bans your IP if it thinks you're doing something bad.  All I did was modify a page it banned me.

You don't go into any detail about what the page won't load means.  Is there an error that is being displayed by the browser?  If so what is it?  In this case it is likely that you are getting some kind of http error code back from the server, or the request is timing out.

You may want to look at your server's fail2ban log.  If Fail2ban is enabled, it is possible that your ip address has been blocked.

Is there an error in a web page?  Do you get a blank page?  If so, does viewing page source show anything?

Errors in the web page are much more likely an sign of something coming from drupal.  Though http error codes could easily be coming from drupal too.

If you use the developer tools in whatever browser you are using to look at the request and response headers what do you see?

This will give you a clearer view of what is being requested and what the server is answering?

Do you see anything in your server's error log?  Does anything show up in the access log?  This will give you a clearer view of whether the request is reaching your web server at all.  If you see no request in either the access or error logs, it is a reasonably good bet that you are being blocked at the firewall level (this includes fail2ban) or that you have some local dns setting that is causing your request to go to the wrong place.  (This could be something in your /etc/hosts)


Drupal 6 Content Types fields not saving I am using Drupal 6 and I am somewhat new to it.

I've been running into a strange behavior.

I have created a new Content Type that have 4 new fields and when I try to make a new Content using this Content Type everything is saved except for the new fields.

Each times that I save the Content the new fields comes out as empty.

I have been looking on search engines without luck, is it a known behavior, is it a bug or is could it be a mismanipulation?

What should I be checking to debug this situation?

The additional fields in question:

Label                     Name                      Type
========================================================
Product Subtitle          field_subtitle            Text
Product Overview          field_overview            Text
Product Features          field_features            Text
Product Specifications    field_n_specifications    Text

These were defined using the UI at: /admin/content/node-type/[content-type-name]/fields

The fields appear correctly when editing/adding new content as well in the listing of the fields in the content type management section.

One final possible oops:  goto admin/content/node-type/TYPE/display and make sure the fields are being displayed in that content type.

If all looks well there, then from the comment discussion, this is sounding like your database might have become corrupted, lost some tables, or generally needs to be restored from a backup taken before all of this started to happen.  If you go into phpmyadmin (assuming you are using mysql) you can check on the following to confirm:

Basically, CCK uses database tables to define the content types it creates, so, you can look for a table called content_type_MYCONTENTTYPE, eg, MYCONTENTTYPE would equal story, page, album, product, etc.

So, if you find that table, it will have as fields/columns the field values of the fields of the content type: nid, vid, and then any custom fields UNIQUE to it in CCK.  By UNIQUE I mean that no other content type uses that field.  If, though, let's say you have a field_overview that you use in other content types also, well, that won't be listed here.

Where?  Once you start sharing a field between content types, it gets its own table, called  content_field_FIELDNAME and in there you will find your content values.

So, in your description above, let's assume the content type is product and that you don't share those fields with any other content type.  In your database, there should be a table called content_type_product and in it you should find fields/columns:

vid
nid
field_field_subtitle_value
field_overview_value
field_features_value
field_n_specifications_value

You should also see fields for FIELDNAME_format that tell drupal the text format.

If you DO share any of these fields, let's say you share the field_overview, look for a table called content_field_overview and in it, you'll find columns/fields for value and format.

So, in a nutshell, that's how CCK works with respect to saving fields and so forth.  If any of the above isn't there, you have to create it or put it back (and of course, try to figure out how/why it got deleted/corrupted in the first place).

If, though, all of the above is there, and there are values in there for your fields, then something else is going on.

Do the values show up when you edit the node, eg, look at a piece of content with those fields, and if you edit it, do those fields have values, or are they blank?  If they have values when you are editing it, then something is causing them to not display.

Did you change or add a text filter that is stripping all your content out?

Did you change your node.tpl.php file and now not printing/displaying these fields for some reason?

Or did you change the display parameters mentioned above at the beginning and they are being hidden or excluded from display?

Anyways, lots to track down but let me know what happened and maybe something else will spring to mind to help track it down to a conclusion.


Conf_path is deprecated but what is its replacement? Im upgrading a D7 module to D8 and it turns out conf_path() is deprecated but I cant find the replacement.

I found a github page that said use this

 DrupalKernel::findSitePath(Request::createFromGlobals())

but I still WSOD when that is called.

One of two change records for conf_path() is Bootstrap refactored to use the kernel. This states that

  Note: In D8, instead of using conf_path(), \Drupal\Core\DrupalKernel::getSitePath() instead. If the kernel is unavailable (such as above, where the code shows the booting of the D8 kernel) or the site path needs to be recalculated then Drupal\Core\DrupalKernel::findSitePath() can be used

So if you have access to the DrupalKernel object, then calling getSitePath() on that object will work. This is probably not the case.

However, there is a service for this called site.path that can be injected into a class that you need it. I think the change record could be updated to reference this factory class.

Using the global Drupal object:

$conf_path = \Drupal::service('site.path');


How to create footer links Does anyone know how to add link such as about us in the footer region. i am using the zen theme. Further, How do you redirect people to the login or register page from pages such as upload, thus if they are not logged in.

You place your menu through the admin/structure/blocks form. Relocate the menu block from the disabled category at the bottom of the form to wherever you wish (footers).  To get rid of the name, select configure for the menu block and enter  in the Title box.


How to check if the page is front page? The following method not returning any value (true or false).

\Drupal::service('path.matcher')->isFrontPage();

How to check if the page is front or not?

This is indeed a way to check if it is the front page and should return a value if you check the method code.

I am using it in a few preprocess hooks:

$variables['is_front'] = \Drupal::service('path.matcher')->isFrontPage();


How to boost relevance of Search API solr with creation date? We have replaced Drupal's core search with SolR but we have noticed a recursiveness issue regarding the search results, for ex. when searching “executive committee”, documents created in 2006 and 2007 are listed before newer documents created in 2010. (http://www.etuc.org/search-page)

What we would like to do is to sort the articles by date and by relevance.

We have tried to alter this at the View level (date + Search:relevance) but it short circuits SolR.

We have looked at the search api settings and it seems that one cannot boost date field. Only fulltext fields are ‘boostable’ (?)

We have also found a few articles related to the subject:

http://www.metaltoad.com/blog/date-boosting-solr-drupal-search-results
How to boost relevance of Search API solr with the value of a certain field?

but they weren’t much help.

We are using Drupal 7, SolR 3 and the following modules

Search API 7.x-1.11
Search API autocomplete 7.x-1.0
Search facets 7.x-1.11
Search views 7.x-1.11
SolR search 7.x-1.4

Does anybody has an idea how to fix this issue?
Thank you very much in advance.

To do this (Drupal 7), one needs to implement the below hook:

hook_search_api_solr_query_alter(&$call_args, SearchApiQueryInterface $query)

This hook can go in the theme or module layer.

Example code could be:

/**
 * Implements hook_search_api_solr_query_alter().
 *
 * @see https://www.drupal.org/node/2009760#find-out-field-id
 * @see https://www.drupal.org/project/search_api_solr/issues/2194055
 * @see https://www.metaltoad.com/blog/date-boosting-solr-drupal-search-results
 * @see https://www.drupal.org/forum/support/module-development-and-code-questions/2014-12-18/extending-search-api-solr-search-with
 * @see https://www.drupal.org/project/search_api_solr/issues/2392499
 * @see https://www.drupal.org/project/search_api/issues/1694698
 * @see https://books.google.com.au/books?id=othpBgAAQBAJ&pg=PA157&lpg=PA157&dq=3.16e-11+solr
 */
function mytheme_search_api_solr_query_alter(&$call_args, SearchApiQueryInterface $query) {
  // Boost more recently created content. This is taken directly from an
  // apachesolr query with +1 boost (+1 for every 100).
  $fields_names = $query->getIndex()->server()->getFieldNames($query->getIndex());
  if (isset($fields_names['created'])) {
    // If using node property 'created', get solr name of it  e.g. 'dm_created'.
    $created_field_name = $fields_names['created'];
    // @codingStandardsIgnoreStart
    // Field name version.
    // $created_field_name = $fields_names['field_date'];
    // @codingStandardsIgnoreEnd
    // Ensure '$call_args['params']['bf']' exists.
    if (!isset($call_args['params']['bf'])) {
      $call_args['params']['bf'] = [];
    }
    $call_args['params']['bf'][] = "recip(ms(NOW,{$created_field_name}),3.16e-11,0.5,0.5)^100.0";
  }
}


use "php code" in page manager access rules to evaluate if current og_group has content of a specific type I'm grateful for the amazing organic groups module (and so many other drupal modules), which I am using for a civil society and social economy network platform.

I have a question, which I think would be interesting for others too. I couldn't find the answer anywhere.

Usecase: I have a page (in page manager) which outputs a tab in og_group nodes, showing a view panel pane of og_group content (together with other panes). Specifically, og_group are organizations, and og_group contents are events. So I'm showing events of each organization in a separete tab.

I wish this tab "events" to be visibile only if there is at least one node of type "event" listed as group content of the og_group page being viewed.

In order to do this, I am trying to use page manager "access rules", which, to quote specific documentation:

  are used to test if the page is accessible and any menu items
  associated with it are visible.

The "only" og related rules available are:

  "Node is an OG group"
  "Node is an OG group content"
  "user membership in group"
  "user permissions in group"

So, I think my logic is possible with the generic "php code" rule. But I'm no coder, yet.

Anybody could give me a hint about what code should I write to check if te viewed node (which is an OG group) has at least one event associated with it as group content?

Thanks!!!

Config: D7 7.41, php 5.2.4, panopoly 7.x-1.28, og 7.x-2.7, ctools 7.x-1.8, panels 7.x-3.5

Update: as @Stefanos suggested in his answer, I am searching for a kind of "no results" behavior of views module, in page manager.

@Stefanos, here is the context available in the page:

Direct answer: To do this with the code you provided, you should use something like the following:

$node = $contexts['argument_entity_id:node_1']->data;
$args = array($node->nid);
return empty(views_get_view_result('rbv_view_group_content','panel_pane_3',$args));

Alternative answer: I have an alternative suggestion, and unless you absolutely want to use the Page Manager, it should allow you to solve your problem without any coding.

So, if you read so far... :-), I would suggest using Views and setting up a path that will 'link' your view to your group node's URL. You are probably already using a view to list your Events. You can set up a page for that view that has a path like the following:

node/%nid/events

You should further configure your page to be rendered as a "Menu Tab", titled "Events".

This Views Page will now be linked to your Group page, and you will be able to handle its behaviour in the case of no results (Events) for that og_group node; for your case to simply hide it.

To get this all working, you would also need to set up your contextual filters to use the og_group nid.

This is a bit theoretical, but I am not entirely sure of your setup.
I hope it helps you though!


caching views based on arguments as taxonomy term id Hi need to enable caching based on taxonomy term id from the url which the views takes as an argument

1)simple cache returns empty results

2)views_arg_cache module also empty

3)views_content_cache module aslo empty

please help if any body has tried such scenario and found the solution

http://drupal.org/project/cache_actions might help you out.

Cache actions provides rules actions for clearing drupal caches.

It currently provides actions for:

  Clearing Drupal cache bins
  Clearing CSS/JS cache
  Clearing The cache of specific views
  Clearing The cache of specific panel pages
  Clearing The cache of specific mini panels


How to add taxonomy term reference field in a custom form In the previous version of Drupal, it was possible to reference taxonomy tags in Drupal's forms using the following option:

'#autocomplete_path' => 'taxonomy/autocomplete/'.$vid,

However, in the Drupal 8, taxonomy term reference field has been removed in favor of Entity reference, more info here.

So, is there any alternative available?

Well, I have found the way in the change records. take a look at: https://www.drupal.org/node/2418529

Here is the example options for taxonomy fields:

'#type' => 'entity_autocomplete',
'#target_type' => 'taxonomy_term',
'#selection_settings' => [
  'target_bundles' => array($vid1, $vid2),
],


How to delete a custom view mode? I have a site that had display suite installed, but the custom view mode I'm trying to delete is not listed in the display suite admin page (admin/structure/ds/view_modes).

So I tried disabling/uninstalling all DS modules, and that didn't seem to help. I re-installed the module and confirmed the ds_view_modes table is indeed empty.

I know I can uncheck the checkbox to disable it for a given content type, but I want it gone completely so it doesn't cause confusion.

In the image, you can see the extra display is called "Classified Ad"

How can I accomplish this?

Check the source code, maybe something is registering it via hook_entity_info_alter


How can I get a display name from the view ID and display ID? I can load a view with $view = Views::getView('my_view_id');, but how do I use that object to load the display_title or say an array containing information including the display name?

Note: This is not to be confused with loading the display's title that might be used when printing the view, as there's a method for that (getTitle()).

After reading throug the docs (https://api.drupal.org/api/drupal/core!modules!views!src!ViewExecutable.php/class/ViewExecutable/8), I tried the following (which worked):

$view = \Drupal\views\Views::getView('your_view_id');
$view->setDisplay('your_display_id');
$displayObj = $view->getDisplay();
//$displayPluginTitle = $displayObj->pluginTitle()->render();
//$displayTitle = $displayObj->getOption('title');
$displayName = $displayObj->display['display_title'];

N.B.1: I use the render function on a TranslatableMarkup object, this is what the pluginTitle function returns. It could be possible to use other functions there, like, e.g. getUntranslatedString
N.B.2: I misunderstood the OP. :-) Commented out the faulty part of the code, which returns the display plugin's title, and not the display's title as requested.
N.B.3: I misunderstood the OP. AGAIN! :-) Commented out the faulty part of the code, which returns the title of the display, and not the display's name as requested. To my defense, that property is labeled 'Display name' and its name 'display_title' (as was mentioned in the OP).

Screenshot from Views example:

And a test script that gets the title of the display (with the output):

Cheers!


Somehow forum's got associated to wrong taxonomy vocabulary. Need help I am using Advanced Forum 2.6 and I noticed that some of the views were set to pull the wrong vocabulary instead of the forum vocabulary. I set them all to pull the correct vocabulary but when I go to /forum the page title is still for the incorrect vocabulary and any change I make at admin/structure/forum also affects the terms in the previously connected vocabulary. It seems that the database is confused and I'm not sure how to reset things.

I am also getting a pair of the following errors for every term:

  Notice: Undefined property: stdClass::$num_topics in
  mothership_preprocess_forum_list() (line 49 of
  /Users/seankennedy/Documents/_IWS/drupal/sites/all/themes/mothership/mothership/functions/forum.php).

  Notice: Undefined property: stdClass::$num_topics in
  mothership_preprocess_forum_list() (line 60 of
  /Users/seankennedy/Documents/_IWS/drupal/sites/all/themes/mothership/mothership/functions/forum.php).

I am mostly a front end guy so I have little experience with messing around in the database directly but not afraid to have a go if that's what it will take to fix it.

Option 1
Go to the Forum Topic manage fields and click edit in the forums field.
Check that the vocabulary is set to Forums
If it's not, delete the forum field and add the term reference field again.

Option 2
Have u posted content already to the forum? or do you care about the forum content? if not, disabling and uninstalling both Forum and Advanced Forum would be an option you could try and then enable them again.


Is it safe to delete the /module folder? I see that the /module folder still exists and a /module/contrib folder has the updated module folders in it.

composer update has updated the site to 8.9
composer update will not update any of the modules still shown in /modules (webform for example)
When running composer update, Composer reports installing Webform 8.5.16, but it doesn't in fact install it and the site still reports Webform 8.x-5.4-beta1

Many other modules are also not updating
The modules in /module are the old versions, while the newer versions are in /module/contrib
Drupal think the modules are in the old path (for example, /module/webform)

What is the safest way to fix the problem?
Delete folders in /module folder other than contrib and rerun composer update?

I have already executed the following commands.

composer composerize
composer cc
composer self-update
sudo rm -Rf composer.lock vendor/
composer update

Yes, you should be able to delete the versions of the modules directly under /modules, and clear cache; in theory that should be enough to get the system to re-register the same modules from their new locations.

Take a backup of the files and database first, and if you want to play it safe, delete one module folder at a time, running drush cr and checking that the version Drupal now sees is correct after each deletion.

It's probably wise to run drush updb after this, in case any of module versions have incremented and there are updates.


Can't find custom block php code in the database I've created a custom block in Drupal 7, to display, in the upper right corner on every page, a menu that is context sensitive.  Based on certain user attributes some functionalities are enabled or disabled.  This block displays a list of available functionality to the user.

small example:

write new article

<?php
    if (og_is_member('node', 12, 'user')){
        print('
Board of directors
');
        print('
statistics
');
    }
?>
<?php
  global $user;

  // Check to see if $user has the administrator role.
  if (in_array('content_manager', array_values($user->roles))) {
            print('
Manage comments
');
  }
?>
Log out

I've noticed that when I make an SQL dump on the live site and put it on my laptop's local database for backup, this context sensitive menu is not there, while on the production site it displays just fine.
first I thought I just had to readjust the visibility settings of this new block on the backup site.  But when I visited admin/structure/blocks the block wasn't even there.  So I figures something must have gone wrong with the sql dump.  So I tried again, still no block in the list.
This new block's name is 'nav_menu_block', so I did a text search on the sql dump from the production site.  Nothing....
So I googled a bit to find out where the data for custom blocks is stored.  Found a few web pages stating this is stored in the table "block_custom".  But when I go there with phpMyAdmin, this table is empty.

So now I have this problem:  if I ever have to put the backup version up again it will not contain this new block, and who knows what else will be missing....

Can anyone PLEASE tell me where to find the data for this custom block with PHP code in the database?

many thanks

Universal solution to find something you know is in the database is:

Dump the entire database to SQL file.

No compression, or uncompress after downloading.
Use one row - one line format - disable "insert many rows in one INSERT statement" and similar options.
Also, disable anything that looks like "save BLOB columns in hex format" - you want serialised variables in human-readable form.

Use grep or similar text search tool to search for the string parts you think characteristic enough to the row you need to find.


How can I get pathauto to generate language-inspecific rules? I have created a new pattern for a specific content type, and did not select any language at the /admin/config/search/path/patterns/XYZ page so that it would apply to nodes in any language.

What I want is for this pattern to be available in every site language. However, when I create new content the alias created has language set to English, and if I navigate to /fr/new-alias it gives 404. I need to manually edit the created URL Alias and set language to "None" for it to work.

I don't see a way to specify this in the pathauto rule. Is it possible or is their a hook I can use in a custom module to force this somehow?

This is currently not possible.

Pathauto always uses the language of the entity, just like the node edit form does.

This is a pretty common scenario and there are feature requests for it, for example: https://www.drupal.org/node/2775275.

There is also a related core issue, about allowing that for manual aliases as well: https://www.drupal.org/node/2689459.

What it needs now is someone to work on those. If you have a budget, you could offer a bounty for someone to work on it. The core issue has a needs review patch, so you could help to test that, that would also help if forward.

I'm considering to implement it in pathauto following the same rules as the core issue suggests, based on whether the path field is translatable or not. That shouldn't be too hard to implement, but it will also need tests.

Disclaimer: I am a (the) pathauto maintainer, you can also contact us (my company) to work on it.


Unpublished content type using rules module based on user role I have a website were there are two type of users, Administrator and Clients.

I would like to add a rule that should apply if the user is Clients.

The rule should unpublished the new content and send an email to administrator.

I have manage to create the rule which is working fine but the condition is not working.

currently the rule is applying to all the user types.

I am confuse what to use as a data selector to apply the rule only to Clients users.

Thanks,

Are you using rule sets and triggered rules?

You should use a Rule set to set the conditions for the specific role and unpublish the content.

Then use the triggered rules to schedule the rule. E.g. When a user updates content run the Rule set


Is it possible to request multiple nodes in one request using Services? I would like to be able to make one request to the Services module node resource and have it return more than one node in the response. Is this possible?

Enable the index crud operation on resources tab. After that you should get all the entities that are accessible to your authenticated request. I had to use hook_entity_info_alter and custom access callback to provide everyones entities of specific type for my api role user.


How to render the field from custom block in node.twig I want to render the custom field from my block in node.twig. As I understand I have to expose the fields from Block to Node variables.

How to realize that?

A node should not have access to a block unless you've done something to add the block to the node. A block can have access to node fields, though (the reverse).

To do what you're talking about I would recommend adding that block to the node in some way. For example:

if you want to add a block as a field in a node:
https://www.drupal.org/project/fieldblock
I would normally use Display suite to then output this block as I want, where I want. But you can also access it via twig template at this point just as you would any other field.

if you're building with paragraphs:
https://www.drupal.org/project/paragraph_blocks


Is Drupal Console aimed to replace Drush? Is Drupal Console (which is available for Drupal 8) aimed to totally or partially replace Drush?

Drupal console is a Drupal CLI tool, from the-ground-up, that leverages Symfony CLI components and modern PHP OOP design practices. Drush is a venerable Drupal CLI tool that has been around since Drupal 4.7, thus built with an older design practice. However, since Drush 9 it's been rearchitected to use the Symfony components as well.

There is overlap based on both projects being a general purpose Drupal administration CLI tool. Drush has more features, due to its age, but Drupal Console has some new features due to its more modern design.

In a commercial software world, there would be some profit motive to merge/buy-mind-share/etc. However, in the open source world they both stand as their own independent projects, with its maintainers motivated for other reasons than to build the one true Drupal CLI tool to bind them all (tm).

It might help to read Ten things you need to know about Drupal Console coming from Ray Saltini of FFW (the company supporting the lead developer Jesus Olivas of Drupal Console), & Drush and the Drupal Console with Drupal 8 from Greg Anderson (one of the maintainers of Drush).

To explicitly answer the question, maybe. If you're wondering which should I use?, the answer is maybe both for the time being. Perhaps Drupal Console will eclipse Drush, but right now both have useful feature sets for administering your Drupal site.


How to set a page level variable that views has access to I'm trying to build a custom responsive theme using Zurb Foundation. I'm also using Views to render a grid of nodes, let's call them Events, that are each wrapped in Foundation classes to lay them out in a responsive grid.

The Problem:

The Foundation classes I need to use need to change based on the visible regions on the page.

For example, if the sidebar_first region is showing, each item in the events list needs to have the classes: columns large-4 medium-6 small-6.

If the sidebar is not rendered, each item needs the classes: columns large-3 medium-4 small-6.

I cannot find a way to evaluate which regions will be rendered at the time the View is being built. I'm currently using template_preprocess_views_view_unformatted() to add the Foundation classes to the Views template, however this hook is being fired well before template_preprocess_page() for example, where I might be able to evaluate the visible regions and set a variable with information about the sidebar.

See the below pseudo code for the ideal structure when the sidebar is rendered:

...

...

...

      ...

...

See the below pseudo code for the ideal structure when the sidebar is not rendered:

...

...

...

...

      ...

Ideally, without the sidebar rendered the events will be 4 across spanning all 12 columns. With the sidebar rendered they will be 3 across spanning only 9 columns, as the above classes in the pseudo code imply.

I must be addicted to Drupal because it is Christmas and I'm working on this, but here goes.

Delete the page display of your view so that only the master display is left. Then create a custom module with this code in it. (I created a module 'custom', my view is called 'zurb', and my path is 'zurb').

In custom module:

function custom_menu(){
  $items['zurb'] = array(
    'page callback' => 'custom_zurb_callback',
    'access callback' => true,
  );
  return $items;
}

function custom_zurb_callback(){
  $view = array(
    '#theme' => 'render_view',
    '#view' => 'zurb',
  );
  return $view;
}

function custom_theme(){
  return array(
    'render_view' => array(
      'variables' => array(
        'view' => NULL,
        'display' => 'default',
        'args' => array(),
        'regions' => array(),
      ),
    ),
  );
}

function theme_render_view($variables){
  $view = views_get_view($variables['view']);
  $view->set_display($variables['display']);
  $view->set_arguments($variables['args']);
  $view->pre_execute();
  $view->custom_regions = $variables['regions'];
  $view->execute();
  return $view->render();
}

function custom_preprocess_page(&$vars){
    if (current_path() == 'zurb' && count($vars['page']['sidebar_first'])) {
      $regions = array();
      $regions[] = 'sidebar-first';
      $vars['page']['content']['system_main']['#regions'] = $regions;
    }
}

Now in your views template file or views preprocess function you can access $view->custom_regions.

Perhaps there is a better way to pass the $regions to the view than adding it as a member on the $view object, but I don't see it being a problem. If it is a concern you can always just use drupal_static

This code is also re-usable as it uses a theme function.


D7 auto nodetitle, title with pattern node:nid and rules php node_save($node) I want to make automatic title like node-333, using auto nodetitle module. When creating node there is no nid, so pattern node-[node:nid] gives me after saving new content "node-". When I edit again this node - title is changing as expected.

So I thought, that using rules I do simple "After saving node" condition "Node type is" and action Execute php node_save($node). But it is not working, I'm getting

PDOException: SQLSTATE[23000]: Integrity constraint violation

Does anyone deal with this or have some workaround?

You are on the right track. I have been doing this for a while now with the following code snippet in rules.

auto_nodetitle_operations_update(array($node->nid));


How do I migrate the "Created" and "Modified" date fields? I created a migration script to test this out.

This is the code I used.

id: article_csv_import
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: Import articles
label: 'Import articles'
source:
  plugin: csv
  path: 'modules/custom/sigtarp_migrate/data/articles.csv'
  header_row_count: 1
  ids:
    - id
process:
  nid: id
  title: title
  body/format:
    plugin: default_value
    default_value: full_html
  body/value: body
  changed:
    plugin: callback
    source: update
    callable: strtotime
    created: date
  created:
    plugin: callback
    source: update
    callable: strtotime
    created: DateCreated
  status: Status
  type:
    plugin: default_value
    default_value: article
destination:
  plugin: 'entity:node'
migration_dependencies:
  required: {  }

When I run the migration script, this is what happen when both the Changed and Created fields are entered.

This is the content of the CSV file used for the migration.

Why is the date off? How can I fix it?

Turns out that for created & changed dates, they are stored differently than field_date's, you must convert these to Unix universal time.

  changed:
    plugin: format_date
    source: update
    from_format: 'm/d/Y'
    to_format: 'U'
    from_timezone: 'UTC'
    to_timezone: 'UTC'
  created:
    plugin: format_date
    source: DateCreated
    from_format: 'm/d/Y'
    to_format: 'U'
    from_timezone: 'UTC'
    to_timezone: 'UTC'


Creating an email newsletter using simplenews I need to create an email newsletter template using simplenews. Can anyone point me to a simple, clear tutorial on how to do so?

I found this links useful

Designing a HTML newsletter for Drupal

http://drupalsteve.com/node/30

Drupal & Simplenews

http://www.slideshare.net/desk02/dug-simplenews-6192093

Email Newsletters and the Simplenews Module
http://www.group42.ca/email_newsletters_and_the_simplenews_module

and probably

Newsletter subscription management in Drupal with E-mail Marketing Framework

http://www.drupalcoder.com/blog/newsletter-subscription-management-in-drupal-with-e-mail-marketing-framework


User Registration to provide password on registration pg administrator approval and verification email [I tried looking for similar answers, I just got this: Administrator notification on user registration

For user registration I want:
1) Password and Confirm Password field on Registration page
2) Admin approval for account creation
3) Verification Email to be sent to the user

* For `Who can register accounts?` the setting says : `Visitors, but administrator approval is required`.
* I've installed the package "User registration password" to have password on registration page as well as getting a verification email sent

Problem: If I don't enable "Admin Approval" registration works fine. The user account is created immediately and it gets a verification email with a link which can be used to confirm the account.

If I enable Visitors, but administrator approval is requirednothing works. User account is created, but it doesn't get a mail, admin doesn't get a mail and account is not activated.

Am I supposed to create a trigger?

With the settings you are currently using, the user creating the account should receive an e-mail. On the admin/config/people/accounts page, near the bottom, look for the vertical tab labelled "Welcome (awaiting approval)". This is the e-mail the user should receive while waiting for the account to receive administrator approval. Check the Recent log messages page (admin/reports/dblog) to see if the e-mail is being sent by Drupal. If it is, check the spam filter on the e-mail account receiving the e-mail.

You will need to set up a trigger so that administrators receive e-mails when new accounts are created. I believe that the superuser account (the user created when installing Drupal) should automatically receive e-mails about new accounts. To notify additional e-mail addresses when accounts are created, see the directions listed at Administrator notification on user registration. You'll need to enable the Trigger module if it's not already enabled. If you want to e-mail all users having a certain role when an account is created (for example, e-mail all administrators), check out the Rules module.

I would also look into the LoginToboggan module. This module also allows the user to enter their password on account creation, but has several other great options. It allows you to set an additional role applied to users when they first create the account but before they verify the account. With this role, you can allow users to create an account and log in immediately, but not perform actions until they verify the account. The LoginToboggan module also allows users to log in using their e-mail address, and display two e-mail address fields on the registration page. I would recommend looking into this module as a replacement for the "User registration password" module you're currently using.


How to obtain raw View result for Drupal 5? How do I get a raw result from a view similar to this $view->result for Drupal 5 ? I would like to get results from the database and run calculations before displaying to the user. I really need to gain access to the the raw data before it's themed by the Drupal engine.

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

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

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

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

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


Performance - custom php block or views to use in panels I use panels to display block with node title on a custom position. My question is about performance - what is faster - to use following php code inside block

<?php
$node = menu_get_object(); print $node->title;
?>

or to use use views to get title of current node.
Thank you

Personally, I don't worry about performance of little things like this.

You also don't need to resort to Views to get this information.

If you are using the Node template page from Page Manager, then you can

edit the page
select the variant
edit the content
click the gear on the panel you want to Add Content
click the Node tab
click Node Title

This will then be a normal panel pane that you can place as you need it.  This is one trick to get node content above the page title on complicated layouts.


Can I print an image from a separate content type in my page--front.tpl.php? This is a question in reference to Drupal 7, using the Zurb Foundation base theme framework. I've created a specific content type that only has an image field in it for purposes of making the image itself content manageable by the user so they can add/remove as they'd like.

I thought that I could access that image with the following code in my page--front.tpl.php file per my Googling of the subject, however, I'm getting no output at all.

<?php print render(field_view_field('node', $node, 'field_my_image_field', array('label'=>'hidden')));
  ?>

I've also attempted several different variations of this to no avail.

How can I access and print out the contents of that field from that content type into my custom page template?

You can embed a view inside your front page template, insert this code in propper region. You'll need an image view

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

replace VIEW-NAME and DISPLAY_ID with your data, you can find those values in last column on your image view


How to test upgrade availability with drush exit codes? I need the test to only do a backup before an upgrade will take place.
I use version 8.01 and I use the following command:

drush up -n

This seems to return zero when there are no updates and 75 when there are, but I need to be sure about this.

Apparently 75 means user abort. Apparently on an up-to-date site, the upgrade process is not interrupted by the "-n" because there is nothing to upgrade and it exits normally.

On an outdated site "-n" will cause the upgrade process to be interrupted and 75 exit code is returned. Please confirm this reasoning is correct, so that I can use it in my script.

The exit codes are defined in includes/drush.inc. Your logic seems sound, but I can't verify that is correct/always will work.


How can I embed a node inside on another node? In Drupal 7 I have a content type created by admin (say content type X), And the other part i have a content type created by users (say content type Y).
Now that is what I do when a user creates content type Y, he can select a node of content-type X to embed node x in node Y.

Without link title node by "References Module" or coding html by "node_embed Module".

You can use entityreference together with display suite and have the display of the entityreference field set to rendered entity. Using rendered entities you can can render any entity with a view mode you need for your display. See this question if you want to create a custom template for the output of that node: How to provide template for particular view mode?


Add placeholder or default value to captcha text field There is a webform in my website, I added the captcha to this webform using this code:

function THEME_form_alter(&$form, $form_state, $form_id) {
    if (strstr($form_id, 'webform_client_form')) {
        $form['my_captcha_element'] = array(
                '#type' => 'captcha',
                '#captcha_type' => 'image_captcha/Image',
        );
    }
}

This works fine. I need to insert a placeholder or default the text field of the image. I mean in the following picture :

the What code is in the image? should move inside the text field. How do I can do this?

Even though it is possible to make this done using javscript but I need to make this done using form alter.

Thanks

you can use this module too:

https://www.drupal.org/project/form_placeholder

it worked for me very nice


How to render taxonomy in page template? I'm trying to show all taxonomy terms in a custom template (page--project.tpl.php) that overrides page.tpl.php, but I can't pull it off.

I'd like to use the default rendering that I get when I see with
render($page['content']):

It seems like I should be able to use render($node->field_project_tags), but I get a bunch of drupal errors on the rendered template page:

Warning: Invalid argument supplied for foreach() in element_children() (line 6590 of /Users/username/sites/d7/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 6047 of /Users/username/sites/d7/includes/common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 6057 of /Users/username/sites/d7/includes/common.inc).
...

What's the cleanest, simplest way to render these taxonomy terms (as links) in a page template?

Use following code to display manually taxonomy terms:

$vocabulary = taxonomy_vocabulary_machine_name_load('vocobulary_name');
if ($terms = taxonomy_get_tree($vocabulary->vid)) {
  $tags ='';
  foreach ($terms as $term) {
      $taxonomy_path = taxonomy_term_uri($term);
      $tags .= l($term->name, $taxonomy_path['path']);
  }
}


How to configure access to courses for teachers and students? In my site I have teachers and students. The student can subscribe to max 3 courses.

I created cTypes:

Modules (which contains the actual information itself) and
Course (which contains a reference to the module)

I create rules:

The moment the student is subscribing to a module I create a instance
of Course. I set a field course.status to active. (list integer)
When the student is ending the course the field course.status is going to deactive.

Questions:

Which access module helps me to organize the student to denied access to the module while course.status is deactive?
Which access module helps me to organize teachers to see information only from students who followed or is following his course?

Everything should be organized by itself or  by rules.

I looked into a custom ruleset with the help of vbo's. I looked into Organic groups and I looked into workbench access and I do not know what to choose. How to keep it simple and effective...

You might want to give it a try to use the Group module, which allows for creating arbitrary collections of your content and users on your site, and grant access control permissions on those collections.

It is available as of D7, and has a D8 version also. It creates groups as entities, making them fully fieldable, extensible and exportable. Every group can have users, roles and permissions attached to it (refer to "What are the various roles supported by the Group module?" for more details about that).

Sample configuration

Below is an example of a possible configuration, which may help to get you started with possible configurations (using the Group module):

Group type ID ! Group type ! Group role ID ! Role
--------------+------------+---------------+------------
 1            ! Class      ! 3             ! Instructor
 1            ! Class      ! 4             ! Student
 1            ! Class      ! 5             ! Alumni
 2            ! Customers  ! 6             ! Lead
 2            ! Customers  ! 7             ! Prospect
 2            ! Customers  ! 8             ! Licensed Customer
 2            ! Customers  ! 9             ! Sales
 2            ! Customers  ! 10            ! Support
 2            ! Customers  ! 11            ! Accounting
 2            ! Customers  ! 12            ! R&D
 3            ! Project    ! 13            ! Project Manager
 3            ! Project    ! 14            ! Developer
 3            ! Project    ! 15            ! Customer

Group Types

The above example consists of 3 group types:

Class.
Customers.
Project.

Group Roles

For each of the 3 group types, there are specific Roles defined, some more details about some of them:

for the Class group, these are the 3 roles that are configured:

Instructor.
Student.
Alumni.

for the Project group, these are the 3 roles that are configured:

Project Manager.
Developer.
Customer.

These roles can be configured per Group type and will only be available on groups of that group type. As an example, for group type "Class", the defined roles are Instructor, Student and Alumni (which are not available for the other group types).

On top of the group specific roles, there are also Special Global Roles: These are the special (hardcoded) roles named Outsider (= a signed in user that did not join a group) and Member  (= a signed in user that did join a group). These cannot be defined by the Drupal administrator, and they are always available for any group. These roles can have different permissions sets for each group type. Special case: the role Anonymous is related to a user that is not signed.

Groups

Each of the configured group types can have any number of Groups.

Examples of groups:

for the Class group type, there could be these Groups:

Getting started with Drupal.
Drupal for site builders.
Become an expert in using the Rules module.

for the Customers group type, there could be these Groups:

Service Requests.
Order Processing.
Sales Orders.
Relationship Management.

Permissions

For each of the configured group types, you can then also configure for each Content Type which Role has what kind of access (= none, view, create, edit, delete). Be aware: even though this looks similar to Drupal's permission configuration, these permissions are not the same permissions (they are specific to the Group module).

Comparison with the Organic groups module

Have a look at my answer to "What are the features of the Group module versus Organic Group module?" for details about:

How both modules (Group versus Organic groups) compare to each other.
Integration with various modules that you might want to take advantage of also.

Resources

Community documentation for the Group module.
Video tutorial "How to use the Group module in Drupal 8 to manage editorial access control to different areas of a web site".

Integration with various modules

The Group module integrates with various other (popular) modules, including:

Rules, as illustrated in the answer to the question "How to bulk assign existing content to a group created with the Group module?".
Views, as illustrated in the answer to the question "How to show the content of a group on the group page when using the Group module?".

The beauty, IMO, of these integrations are that they are more or less out-of-the box (not dozens of extra modules needed to make those integrations work).

Addressing your specific questions

  Which access module helps me to organize the student to denied access to the module while course.status is deactive?

Probably the easiest implementation of this, is to use the Rules module to create an appropriate "Group Membership" entity, which is what it takes to grant a user access to a Group. And assuming you have something in place that allows you to create a view of all students (users) that at some point should receive access to some course, you could use the Views Rules to create such entity for each user in such views result, and thereby using some Rules Event(s) / Condition(s) related to the update of course.status from deactive to something like active.

  Which access module helps me to organize teachers to see information only from students who followed or is following his course?

This is by design of the Group module (just a matter of appropriate configuration of the Group module).

PS: this answer applies to either D7 or D8.


How to update the version of AngularJS using module configuration I'm trying to build an application using Drupal and AngualarJS. When I download and enable the drupal-angualar module(https://www.drupal.org/project/angularjs) it shows the top version as 1.3.4, but I want to use the latest angular version(1.5.8).

How can I update the angualar version to latest?

As @Jimmy Ko suggested I have fixed the issue as follows:

I have added the following code in the function angularjs_version_files() of file sites\all\modules\angularjs\angularjs.module. Then selected the AngularJS version 1.5.8 in admin/config/development/angularjs.

$files['1.5.8'] = array(
    'angular-animate',
    'angular-aria',
    'angular-cookies',
    'angular-loader',
    'angular-messages',
    'angular-mocks',
    'angular-resource',
    'angular-route',
    'angular-sanitize',
    'angular-scenario',
    'angular-touch'
  );

Now, in the view source I can see the latest AngularJS file is included in my project.


Commerce Point of Sale (POS) I do not know how to use the last module "project/commerce_pos" version 2 dev. I can not even get a view point of sale. Can you tell me how to access the point of sale? there is no documentation.

I know how to access the settings, but I can not access the page above to use the pos

I do not see how to add products

You will find some documentation in the README.txt that comes with the module.

To use the module, you first need to get drupal commerce up and running. Then your products will be available for sale via the POS, once installed.

Also look at the commerce pos issues queue as v2 still has some issues being resolved.

I have used 7.x-1.x-dev extensively, and you can access the POS via: admin/commerce/pos

The configuration is via: admin/commerce/pos/config

If you have any specific question, please amend your original question.

Edit:

Make sure you are using the latest 7.x-2.x-dev version to get latest fixes.
Also see this issue relating to products not showing: By default, no products are available in the POS
POS is available via: admin/commerce/pos


Redirect to view display after form submission I'm using a form_alter hook to add a custom submit callback. I want to redirect the user to a particular page display of a view. However, I'm having trouble figuring out how to specify the path.

In my custom submit hook, I tried $form_state->setRedirect('/my-view/page/path'); but that didn't work. From searching, I found this question, Redirect after form submission, but the answers indicate to specify the machine name of a path from a routing yaml file.

I'm wanting to redirect the user to a views page display that I built in the UI, so I don't have any routing.yml file (that I'm aware of) where I could glean a machine name of a path from.

How do I set the redirect in a custom submit handler to a page display of a view?

Routes are not only defined in yaml files, but also dynamically in route subscribers.

Drupal\views\EventSubscriber\RouteSubscriber collects routes from all views displays which implement DisplayRouterInterface::collectRoutes, like the Page display:

PathPluginBase::collectRoutes:

  public function collectRoutes(RouteCollection $collection) {
    $view_id = $this->view->storage->id();
    $display_id = $this->display['id'];

    $route = $this->getRoute($view_id, $display_id);

    if (!($route_name = $this->getOption('route_name'))) {
      $route_name = "view.$view_id.$display_id";
    }
    $collection->add($route_name, $route);
    return ["$view_id.$display_id" => $route_name];
  }

This produces route names like view.my_view.page_1 and you can redirect in a form submit:

$form_state->setRedirect('view.my_view.page_1');


Panels, menus, and path in Drupal 6 I'm trying to work on a site that's using Panels to, among other things, create a sidebar navigation menu. It's working well on a page that exists in the menu tree structure:

Primary links

Info Page

One type of info
Another type of info

Updates

One category of updates
Another category of updates

Another page

With some subpages
Of its own

On the Updates the menu (correctly) appears as such:

Info Page
Updates

One category of updates
Another category of updates

Another page

I want to create essentially the same structure, with only a selected part of the menu expanded, but on pages that are not themselves part of the menu structure (i.e. individual updates within the categories of updates). Ideally I'd like to do this based on the path alias or content type or something of that nature, so all updates show a menu with the whole updates category expanded (but not Info or Another)

How do I do this with Panels in 6.x?

I ended up doing this with the Menu Position module and Menu Blocks module as well as Panels.

Create a Menu Block with

Parent item:

Menu: Primary Links
Item: <root of primary links>
Starting level: 2nd level (secondary)

Create a Menu Position rule:

Content Types:

Update

Menu item:

Updates

Add your menu block as panels content (if desired) to the nodes of the desired type.


Redirect the users to the page they were watching before logging in or registering an account I have a custom login, sign-in and sign-up page in two tabs; I want logged-in users to be redirected to the same page they were watching before logging in or creating an account.

How can I achieve this?

I hope you want to keep users on the currently visited page after logging in or out. If it is so, then download and install the Login Destination module. It is also possible to keep users on the currently visited page after logging in or out.


Correct SQL Statement for Joining Taxonomy Terms I have 2 different taxonomy vocabularies setup.

Courses (First Aid, H2S Alive, Air Monitoring, Gas Detection,
etc...)
Locations (Vancouver, Calgary, Toronto, Montreal)

I have a content type called Landing Page for each of the courses that has a taxonomy reference field so you can assign a course or multiple courses to that node.

I have a second content type for Courses which also has the 2 taxonomy vocabularies set as taxonomy reference fields on its nodes. These course nodes get displayed in a calendar format and is setup with the entity registration module.

WHAT I NEED HELP WITH:

Im looking for a way to output a set of buttons on the Landing Page nodes that will give me a the list of locations that have been assigned to any node that is based on the given Courses taxonomy term.

For example;

3 Different Courses nodes all have First Aid assigned to them. However, they have 3 different locations set to them.

I've created a landing page for the First Aid Course assigned it the First Aid taxonomy term. I need to display a set of locations that this course has courses offered at.

If you want to show Locations a Course is offered. Or Courses at a Location I would recommend using the Views Field module, or perhaps Context to show a View on the content type page.

Views field allows you send parameters to the embedded field view from the source Node. So you should be able to get the related content(s) you want to show by passing the necessary filter parameter criteria you want to the View -- usually as a contextual filter.

For example for a Landing Page Content Type (eg, First Aid) you add a field that is a View. Call the view like locations for course. Then make a View that outputs Location taxonomy term names based on a contextual filters. The contextual filter will be:

the taxonomy term name of the course(s) in your taxonomy of Courses.

Then output the taxonomy Location term names for results of the set course name contextual filter. Overwrite the linkpath as needed.


Taxonomy term view with number of items for parent and child terms For my shop, I need a taxonomy tree view with 2 levels, the number of items should be shown in brackets for every parent and child term.
My problem: it works for the child terms, but not for their parents.

This should my view look like:

parent-term-1 (15)
- term-1.1 (7)
- term-1.2 (8)

parent-term-2 (15)
- term-2.1 (6)
- term-2.2 (9)

But it looks like this:

parent-term-1 (0)
- term-1.1 (7)
- term-1.2 (8)

parent-term-2 (0)
- term-2.1 (6)
- term-2.2 (9)

My view
Vocabulary Name = Category

Relationships
Taxonomy Term: Parent term (Identifier = Parent)
Taxonomy Term: Content with term (Identifier = node)

Use aggregation: Yes

Fields
Taxonomy Term: Term ID (Exclude from display)
(Parent) Taxonomy Term: Term ID (Exclude from display)
Taxonomy Term: Name
(node) COUNT (Content: Nid)

Filter criteria
Taxonomy vocabulary: Machine Name=(Category)

Format
Format: Tree (Main field: 1st Term ID, Parent Field: 2nd Term ID)
Field Settings: 3rd + 4th field inline

Any ideas?

I now have worked out a solution. You need to implement the taxonomy edge module. With that you can define a new relationship: Taxonomy term: child term. After that it's possible not only to count the number of nodes tagged with one term, but also the number of nodes tagged with the child terms of this term.

My nodes are always tagged with terms from the deepest level. So I have to consider the number of nodes tagged with the considered term OR the number of nodes tagged with the childs terms of the considered term (if available).

Completing my initial post, I add two relationships:

Taxonomy term: Child terms (Identifier = Childs)
(Childs)Taxonomy Term: Content with term (Identifier = node_childs)

I further add one field:

(node_childs) COUNT (Content: Nid)

In the field settings, i set these fields inline:

Taxonomy Term: Name
(node) COUNT (Content: Nid)
(node_childs) COUNT (Content: Nid)

The field (node) COUNT (Content: Nid) is excluded from display.
In the field (node_childs) COUNT (Content: Nid) I set the No-results-behavior to the token [nid].

The effect is that either the considered term has child-terms, then the number of nodes tagged with the child terms is counted. Or the considered term has no childs, than the number of nodes tagged with the considered term is counted.


Trigger an action at a specific time using Trigger and Rules I would like to run an action once a specific $_SESSION variable is set. In both Trigger and Rules, I do not find a description on how to do something like that. Can anybody help me, or at least hint at a website explaining this?

I am looking for an easy way to initiate a call at a specific time (think of as a Drupal alarm clock); my idea was to put the time in a $_SESSION variable and fire the alarm clock once $_SESSION['alarm'] == strtotime("now").

In case that this should just not be possible: I would also be happy with a trigger that fires whenever I go on a certain page.

Why are you interested in the $_SESSION variable? What is the bigger action you are trying to accomplish?

The easiest way to fire any event when a user visits a page in Drupal is too use hook_menu and create a custom callback.

If you are trying to fire an action at a specific time you can setup a cron job to go off at the time you desire.  Drupal 7 core has a built in cron mechanism you can tell to go off at certain time increments /admin/config/system/cron . If you don't have access to your server to setup a cron job and want it to go off at a specific time once a day (ala an alarm clock)  you can use one of these modules Advanced Cron Modules

In order to respond to a cron job you can use hook_cron or using a cron trigger at "/admin/structure/trigger/system"


Auto add shipping line item I want to auto add flat rate shipping cost to any order and display it in the shopping cart summary.

I am using Commerce Shipping and Commerce Flat Rate modules. I can't know how to implement it using rules.

I found this post but it didn't help me.

what I need is to automatically add $10 on every order for shipping, I will disable the Shipping Service Panel.

You can do this with Rules. Here is an example:

{
    "rules_auto_add_shipping_service" : {
      "LABEL" : "Auto-add shipping service",
      "PLUGIN" : "reaction rule",
      "OWNER" : "rules",
      "REQUIRES" : [ "rules", "commerce_order", "commerce_shipping", "entity" ],
      "ON" : { "commerce_order_update" : [] },
      "IF" : [
        { "data_is" : { "data" : [ "commerce-order:type" ], "value" : "commerce_order" } },
        { "commerce_order_contains_product" : {
            "commerce_order" : [ "commerce_order" ],
            "product_id" : "YOUR-SKU-HERE",
            "operator" : "\u003E=",
            "value" : "1"
          }
        }
      ],
      "DO" : [
        { "commerce_shipping_delete_shipping_line_items" : { "commerce_order" : [ "commerce_order" ] } },
        { "commerce_shipping_method_collect_rates" : {
            "shipping_method_name" : "flat_rate",
            "commerce_order" : [ "commerce_order" ]
          }
        },
        { "commerce_shipping_rate_apply" : {
            "commerce_order" : [ "commerce_order" ],
            "shipping_service_name" : [ "" ]
          }
        }
      ]
    }
}

Just change the SKU or the other conditions to suit your needs.


Why is my theme function not called (not in template file)? I have a simple theme and everything is by documentation/examples:

function activit_theme() {

  return array(

      'activit_package_teaser' => array(
          'arguments' => array('node' => NULL),
          'type' => 'module'
      ),

  );
}

+

function theme_activit_package_teaser($node) {

  $output = '

      package

  ';

  return $output;
}

and

function activit_packages_block() {

  $nids = db_select('node', 'n')->fields('n', array('nid', 'status'));
  $nids->join('field_data_field_important', 'f', 'f.entity_id = n.nid');
  $nids->fields('f', array('field_important_value', 'entity_id'));
  $nids->condition('n.status', 1)->condition('f.field_important_value', 1);
  $nids = $nids->execute()->fetchCol();

  $nodes = node_load_multiple($nids);

  $packages = '';
  foreach($nodes as $node) {
    $packages .= theme('activit_package_teaser', array('node' => $node));
  }

  return '

'.t('Important packages').'

        '.$packages.'

  ';

}

there are 4 nodes, but my theme is not called at all and nothing is inserted into

. No error in "recent log messages".  Why it does not work?

UPDATE: When the template is in activit_package_teaser.tpl file it works:

  'activit_package_teaser' => array(
      'arguments' => array('node' => NULL),
      'template' => 'activit_package_teaser',
      'path' => drupal_get_path('theme', 'activit') . '/templates/',
  ),

But why it does not work as a theme function?

arguments was for Drupal 6, you need to use variables for Drupal 7.  One of variables or render element is required, hence nothing is showing up at the moment as the item isn't making it into the theme registry.

function activit_theme() {

  return array(

      'activit_package_teaser' => array(
          'variables' => array('node' => NULL),
          'type' => 'module'
      ),

  );
}


Entity custom displays Is there a way to create multiple displays for an existing entity?

The node has already Full content, Teaser, RSS, Search index, Search result display types. I was wondering if I can add more to these or to any other entity.

Thanks :)

I think this is the answer I was looking for:

function hook_entity_info_alter(&$entity_info) {
  $entity_info['entity_type']['view modes']['custom mode'] = array(
    'label' => t('Custom view mode'),
    'custom settings' => FALSE
  );
}


What are Hooks, Actions and Triggers in basic terms In basic terms what are hooks,actions and triggers.

My ideas are that hooks allow you to do something when an event takes place and that the "something" is the action.

I am having a bit of trouble figuring out where triggers fit into the equation.

Hooks are one concept, and actions-and-triggers are a separate concept.
See What is the basic concept behind hooks? for the canonical explanation of hooks (there are some excellent answers to that question, there would be no point in trying to reproduce them here).
Actions and Triggers are best explained in Using the new Actions and Triggers functions in Drupal 6 (the concept is the same for Drupal 7).
From that page:

What is a trigger?
Triggers are Drupal events such as saving or updating a post, a user logging in or someone viewing a piece of content. Think of it like a trigger for an argument – when the trigger happens (ie. A disagreement), an Action happens (the argument). This allows you to heavily customize Drupal and paves the way to amazing new implementations of the software.
What is an action?
Actions are something that happens after the trigger. For example, you could redirect the user to a page, send an email notice to administrators or display a special message. This can allow you to integrate Drupal into other systems.

You might also be interested in the Rules module which is

a replacement with more features for the trigger module in core

It's far more powerful than the trigger module and has a lot of extra features.


hook_entity_presave showing error in commerce kickstart I have created a field calculated price in commerce add product, the code used to save calculated price on saving product.
function custom_module_entity_presave($product, $type) {
  if ($type == 'commerce_product') {

$cal=commerce_product_calculate_sell_price($product);
$currency_code=$cal['currency_code'];
$amount=$cal['amount'];
$total_amount = commerce_currency_format($amount, $currency_code);

$product->field_calculated_price['und'][0]['value']=$total_amount;
//commerce_product_save($product);

}
}
But this code showing error on saving product

Try the code without using the following line.

$total_amount = commerce_currency_format($amount, $currency_code);

The remaining code will be the following,

function custom_module_entity_presave($product, $type) {
  if ($type == 'commerce_product') {
    $cal=commerce_product_calculate_sell_price($product);
    $currency_code=$cal['currency_code'];
    $amount=$cal['amount'];
    $product->field_calculated_price['und'][0]['value']=$amount;
  }
}

If this code not showing error, then the problem will be on your field_calculated_price field type. I think it is a custom field and the problem is the field type is not compatible with commerce_currency_format.

Please make try... Hope this will help you.


Core updates and module updates: Does order matter? I inherited a badly out-of-date Drupal 6 multi-site instance.  There is only the production instance. (yeah, that gives me a warm-fuzzy!)

Many modules are several versions behind and the core is several versions behind.

Does the order in which I perform the updates matter?  I'm thinking update core first, then update the modules, but I'm just not sure.

Anyone care to advise?

Order does matter.

Sadly, it's hard to tell exactly how it will matter in your situation. If you can, make a dev copy of this site and experiment on it. I would either go with core-first or with all at once. But that's my intuition, and actual tests on a copy of actual site matters much more.

Usually it's OK to jump all versions in-between the one you have and most recent one. For modules, sometimes, rarely, it's good to use most-recent minor version and don't install next major version at all (if both are maintained), or install most-recent minor and then update major. Sadly, it's different for each module, so fastest thing would be to update everything straight to the recent version, and see if / what broke. Of course, this is only feasible on a dev copy, not production.


Notice: Undefined index: tid in taxonomy_field_formatter_prepare_view() (line 1669 of I'm getting this error on my website. I have tried cleaning up the content type of all fields but it still shows up.

Any ideas what could be causing it, and how to debug?

Thanks a lot,

Chiko

Your content have an taxonomy_term reference field which have invaild data, maybe it break.

You can install devel module and use error display with debug_backtrace and you will see where it comming.


Search Results page. Move the search form after the results? Apparently the only template file to edit is for an individual search result, located at core/modules/search/templates/search-result.html.twig. So you can't move the search form after the results and style accordingly?

Just want to double check this.

Short answer. If you're looking for a twig template to move around the search form, no you can't.

Long answer. Drupal core search dynamically builds its search routes for all searchable entities then handles the page render via SearchController::view(). The controller view method only defines the theme functions/templates for the search results, not the search page as a whole.

If you wanted to move these around the render form & results elements,
It's possible to override the search routes via a custom module so the  _controller property points to a custom controller that extends SearchController and defines a view() method that does something like:

// in my custom search controller:
public function view(Request $request, SearchPageInterface $entity) {
  $build = parent::view($request, $entity);
  // @TODO: alter $build render array so form / results are re-ordered
  return $build;
}


How to access fields attached to taxonomy term in views-view-field.tpl.php? A vocabulary has an additional field field_information attached. In a view i just want to render this information field exclusively (without term name etc). In my views-view-field.tpl.php I did a dpm($field), but I can't figure out how to get to the value of field_information.
Unfortunately due to my setup I can't use the module taxonomy_field_formatter, I'll have to do it manually.

Puh, finally I found a way.
This is my template file views-view-field.tpl.php (instead of a custom field I used the description field, but that doesn't matter in this case):

<?php
if (isset($row->_field_data['nid']['entity']->field_myfiled['und'][0]['tid'])) {
  $tid = $row->_field_data['nid']['entity']->field_myfield['und'][0]['tid'];
  $term = taxonomy_term_load($tid);
  $output = $term->description_field['und'][0]['value'];
} else {
  $output = $output;
};
?>

<?php print $output; ?>


How to prevent views from loading the results upfront I have views block with exposed filters and ajax enabled which was rendered in home page, the problem is when the block is loaded with exposed form views is loading the results too. However I want the results needs to be shown only when the user clicks on the submit button.

If I enable input required, this will work, but the client doesn't want this.

Here is the way to solve your issue:

Add Contextual filter of "Global: Null" type
In "When the filter value is NOT available" section check "Provide default value" and specify "Fixed value" and "all". Notice! If view still display results - then try select "Raw value from URL" here.
In "When the filter value IS available or a default is provided" section check "Specify validation criteria" and select "PHP code"
Specify this code

if (count($view->exposed_input)) {
  return TRUE;
}
In "Action to take if filter value does not validate" select "Display all results for the specified field" value
Don't forget to add any "No results behavior"!

Now results will be shown ONLY if filters are sent. View will be empty on       first display.


jQuery once callback function is not called I'm struggling with the once function. The once callback function is not called. I'm trying to use like this:

(function ($, Drupal){
  Drupal.behaviors.my_module = {
    attach: function (context, settings) {
      console.log('this runs');

      $('.my_selector', document).once('special-mark', function() {
        console.log('this never called');
      });

      console.log('this also called');
    }
  }
})(jQuery, Drupal);

In the library file I use the following:

dependencies:
  - core/jquery
  - core/jquery.once
  - core/drupal

There's no a single error in the console. It's just simply not called the callback... How can I make it work?

Drupal: 8.8.4
jQuery: 3.4.1

jQuery once doesn't take a callback as a second parameter. You need to loop over the returned list of elements and apply a callback using one of the standard methods like each:

$('.my_selector', document).once('special-mark').each(function() {
  console.log('this will be called');
});


Printing fieldable panel pane custom field in template properly I've created a fieldable panel pane that has two fields, a title and a body. My template file looks like this:

        <?php print render($content['field_pane_title']); ?>

        <?php print render($content['field_body']); ?>

This seems fairly basic. Now, when I actually add one of these panes to a page, this is the DOM that is spit out:

    Test Pane

This is a test body.

Ignoring the fact that it's printing out empty field-label elements, why is the pane-title field being printed outside the pane-title h2 element? Is there a better way to be doing this? Thanks!

Ignoring the empty field-labels was a problem! The issue was with those field labels, which were generated by the Fences module. They were somehow causing the h2 to close too early.

I ended up modifying the module myself, so that the template checks if a field label exists before adding it to the DOM.

I also ended up finding an issue on the module's issue page which has a patch to fix it directly, in case anyone is interested: https://www.drupal.org/node/2605808


How to substitute values on a page, without PHP? There are certain values that are liable to appear in many places on my site (corporate-owned stores, independent stores, # of brands carried, and so forth) that content authors and editors are not likely to keep up-to-date very well on every single page in which they appear.

I can put them in variables in (e.g.) settings.php, and then put PHP snippets in any nodes that need to use them, but that has obvious downsides:

content authors cannot update the values when they change
content authors cannot edit the text that contains the PHP snippets
unless of course I give them permission to do that, but that's probably not a great idea

I'm currently experimenting with using the Token Filter module to allow putting tokens like [node:field_corporate_stores] in content fields in a node.  This works just fine if that field is on the node that also has the body content in which it is being replaced.  But of course that would defeat the purpose: I want one node that contains the values, and to be able to use an indefinite number of other nodes that will consume the values.  But I don't see how to do that.

How do I define data_node for a token like [data_node:field_corporate_stores]???  (Without using any PHP snippets in the node.)

This is even more new than Beta, but look at the Sandwich module that looks like most of its configuration is in 1 place (across all nodes of X type for instance).

The module sits at ~400 lines of code and has it looks like 2 small example usage modules/themes.

EDIT: to be clear this goes off custom markup I believe like, MY_CUSTOM_VALUE, in a body field of a node which would regex out to be whatever value you implement in a module. With page caching turned on shouldnt be a huge hit. You keep your "values" in code and dont depend on the Token module.


How to limit posts per hour? In order to fight spammers, I'd like to limit the number of threads and posts that authenticated users can create per hour. What is the easiest way to do so?

Flood control module in addition to the modules mentioned in this duplicate question

From module page

  This project is intended to add an administration interface for hidden flood control variables in Drupal 7, like the login attempt limiters and any future hidden variables.


How to select state on country bases in drupal webform How to select the state on country bases in drupal.I have different country and states now I want to select the state on the country bases. I have installed the webform module and webform conditional field module. How I can do this task.

Use the Webform Simple Hierarchical Select and the Simple hierarchical select modules; just create a vocabulary and add countries and states hierarchically.

If you don't have vocabularies for countries and states, using the Taxonomy Manager module helps you to import countries and states from a simple list like the following.

United Stated
- Alabama
- Washington
Iran
- Tehran
India
- Mbambi


Saving 'sub' from Identity Provider I need to associate sub, which is received as part of $userinfo in openid_connect_save_userinfo, but I don't see it as part of the claim options.  I also don't see that it's stored elsewhere.

I am using the openid_connect project.

I'm wondering if I'm missing something in configuration and maybe I need to do something custom.

The association is stored in openid_connect_authmap and there is a service: openid_connect.authmap to access it.

Without DI:
\Drupal::service('openid_connect.authmap')
  ->getConnectedAccounts(\Drupal::entityTypeManager()->getStorage('user')->load($userid))


Get the actual query executed by a view I need to find out the SQL query that is executed by a certain query. Views module can show the SQL when configuring the view but apparently the query is not the actual query that gets run in all cases.
I am aware that the Devel module can show the database queries, but there is no way with devel to show the actual queries except clicking the associated 'A' link with every query and there are hundreds of them.

How can I find out the actual query that the view executes? The view is displayed as a block.

You have to use hook_views_pre_execute and with Devel installed use dpq to view the SQL String:

function hook_views_pre_execute(&$view) {
  dpq($view->build_info['query']);
}


How to remove 'Main Menu' from my mobile view (using Superfish)? I am using Bootstrap Business theme and I put Superfish module in my theme.

The problem is when it appears in Mobile View the title of "Main Menu" appear.

I would like to remove that title. However, I don't know how to make that.When click on the menu, it also involve that title.

Any suggestions?

Go to admin/structure/block and look for Main Menu (should be in the Superfish region).

Click configure and set the title to not display. As the instructions for the Block title field say:

  Override the default title for the block. Use <none> to display no title, or leave blank to use the default block title. This field supports tokens.


Drupal security measures I have got a list of security violations for my website from security team. It says

  Cookie without HttpOnly flag set

  Autocomplete Password Enabled

So, what is this basically? Can I overcome this in my Drupal 7 site?

Ask for the actual security report.  They often contain explanations about what the problem really is, as well as offering a solution.

I believe this will take care of the password autocomplete issue; I have a client who requires this and have it deployed on a few sites.

function mymodule_form_alter (&$form, &$form_state, $form_id)
{
  // http://www.midwesternmac.com/blogs/jeff-geerling/disabling-autocomplete-forms

  if ($form['#id'] == 'user-login') {
    $form['#attributes']['autocomplete'] = 'off';
  }
}


Watchdog reports many spammy looking page not found warnings Periodically, I like to run the following command to see what kind of activity and errors are going on with our website in real time.

drush ws --tail --full

Every second or so, there is a page not found error, but the pages are things that have absolutely nothing to do with the content of our website, following our Drupal URL format. Our site has been migrated a few times and may have old content from a long time ago, but again, this content doesn't relate at all to our subject material. Does anyone know what might be happening or if this is normal?
How do I stop the command from running?

Thanks!

Pretty much every site online is being scanned by bots looking for security holes. The more popular the site, the more common this is. They don't necessarily follow links from the site itself, and even on Drupal sites you'll see requests for paths like "/wp-admin".

And you can exit via Ctrl-C.


Customizing the display of properties on a rendered entity I have a custom entity with a large amount of properties on it.

We want to format these entity properties to look a certain way, without modifying the underlying data in the table.

What is the most idiomatic (the most Drupal) way of doing it?

We're trying to put an Entity Reference of this custom entity on a node and render only a few fields - with a form of preprocessing or something along those lines so that we can control the ultimate output.

I can get the fields to show with this key => value pair in the entity array in hook_entity_info():

'extra fields controller class' => 'EntityDefaultExtraFieldsController',

But it doesn't seem to give me any control over the output.

Alternatively, I can put all of the properties into $entity->content in hook_entity_view() as such:

foreach ($entity as $field_name => $property) {
  if (in_array($field_name, $properties)) {
    $entity->content[$field_name] = array("#markup" => $property . "<br />");
  }

But this doesn't seem very idiomatic.

This seems like a problem that I can't find a lot of resources on.

We're trying to put an Entity Reference of this custom entity on a node and render only a few fields - with a form of preprocessing or something along those lines so that we can control the ultimate output.

Sounds like hook_entity_view is what you want. Use "teaser" or create a new view mode, and attach the reference using the given view mode, then implement your logic to render the properties as you like.

Alternatively / additionally, you could look at Display Suite and DS Extras which will give you more flexibility to expose properties via DS custom fields or in field templates.


How can I hide a field in the node add form but it unhide it on the node edit form? I'm having a content type in that I want a field "Status" to be hidden in add content form page(I'm setting default value in that add content). Now I want that field to appear in edit form page of that node and user can able to edit it. I'm new to Drupal, so I don't know how to do this.

You can Show/Hide the status field using hook_form_alter like this:

function MYMODULE_form_node_form_alter(&$form, &$form_state) {
  $node = $form_state['node'];

  if (!isset($node->nid) || isset($node->is_new)) {
    $form['YOUR_FIELD']['#access'] = FALSE; // Node is new!
  }
  else {
    $form['YOUR_FIELD']['#access'] = TRUE; // Node is not new!
  }
}

Then replace YOUR_FIELD with the field name of your status field.


Attribute about not allowed on element article at this point While i checked the markup of my drupal-7 site in http://validator.w3.org/check
it shows me a error:

error Details:
Attribute about not allowed on element article at this point.

I have checked my markup as well as all the functionality that are running properly. Why i am getting this error?

It looks like there is a markup error somewhere whereby you have an <article> tag with an about attribute (i.e. <article class="my-class" about="blah">).

I would imagine the site is working fine as the attribute will just be ignored if it's not applicable, so I'd find the page and line from the validator error and double check your markup.

You could also try running it past the newer HTML5 W3C validator at http://validator.w3.org/nu/ just in case.


Path field gives wrong url I made change in setting.php for base url

$base_url = 'http://www.example.com/drupal

Pattern for this content type paths are

[node:title]

pathauto works ok, in the database path is exactly as pattern.

Problem starts when I want to print Content:path in view I am getting

/drupal/[node:title]

I have a problem with path field because I want to rewrite result for logo field using

[field_company_logo]

And link is http://www.example.com/company/[nid]/drupal/[node:title] instead of http://www.example.com/drupal/company/[nid]/[node:title]

Changing the $base_url variable by no means makes drupal look through every bit of text in the system checking for href's.  So, if you put in

 <a href="/company/.....

it is going to use it exactly as is because it has no idea to do anything else.  It will, however, be more than glad to put it in front of a path if you use some of its built in functions, for example:

 <?php print l('Foo Bar Baz', 'company/foo/bar/baz'); ?>

will create a link to /company/foo/bar/baz if $base_url is not set, or if it is set to drupal, to /drupal/company/foo/bar/baz.

So, to your problem.  Have you tried Views' Output as a link instead of creating the <a> ... </a> code yourself in Rewrite the output of this field?  That should put that $base_url in there automagically if in the Link path: you enter company/[nid][path] (or whatever tokens you need as you use several different ones in your question).


How can I change the 'active' class in main menu to something else? I'd like to change the class in the main menu from 'active' to say 'current'.  How can this be accomplished?

Assuming you are using Drupal 7.

You can overide theme_links in your own theme.

find the line:

$class[] = 'active';

make it

$class[] = 'current';

check API:

http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_links/7

by the way, I would suggest you not to change 'active', instead you can just add additional class for it.  As many contributed modules use the default 'active' class. Such as SuperFish, Menu Block


Backup & Migrate scheduled backup silently fail I've tried to use backup & migrate for backups on my omega8 based aegir server.

Although I've defined a schedule, and setup cron interval to 1 hour, it doesn't work - no backups are generated. Scheduled backup silently fail.

Attached is a screenshot of the current schedule:

Notes:

Module's permissions are default (all marked V for admin).
Backup profile is the default as well.
I'm using Drupal 7. Module's version is 7.x-2.7

Any idea?

It is because you are using buggy module with known issues. This has nothing to do with BOA nor Aegir. There is a reason why we have removed this notoriously buggy module from BOA recently. You should report any such issues in the backup_migrate issue queue on drupal.org - and you may find them reported already, in fact.

This module may still be useful, but only if you follow its issue queue and use release which happens to work. The regressions rate in this module is way too high for us, so we no longer include it by default. Just one example:
https://drupal.org/node/1997354
and a fix:
https://drupal.org/node/1997354#comment-7426824


Call to undefined function db_set_active() I sure I have succeed to use these snippets in previous code, but now I get a "Call to undefined function db_set_active()" error. I don't understand why.

public function allUnits() {
  global $dbUtil;

  $list = array();
  $qryStr = "SELECT * FROM unit ORDER BY u_id";

  db_set_active('mpd_pro');
  $rs = db_query($qryStr);

  while ($row = $rs->fetchAssoc()) {
    $list[$row["u_id"]] = $row;
  }

  db_set_active('default');

  return ($list);
}

The 2 things that come to mind: your installation is  not bootstrapping properly (improperly configured .htaccess or settings.php) , or you installation is corrupt.

I would recheck the apache logs, watchdog logs to see if any errors are mentionned, if all fails I would see if the application works with this module disabled, because this function is defined in core on line 2519 in includes/database/database.inc and should be available from all your custom module code.

Hope this helps, cheers!


Quicktabs: output divs instead of list I am quite new to theming, and I am trying to figure out the right way of theming Quicktabs in D7. I would like to output the tabs as divs instead of as a <ul> list. Looking at info from Theme Developer tells me that the Quicktabs are defined by qt_quicktabs_tabset which in turn calls theme_item_list() .

I could override theme_item_list() in my template.php file, but it would require a lot of tweaking because the theme_item_list() is designed for outputting a list. So for the moment my approach is to make a new theme function available in a custom module  like this

function mymodule_theme() {
  return array(
    'mymodule_hook' => array(
      'variables' => array ('parameter' => NULL),
    ),
  );
}

function theme_mymodule_hook($variables){
  //here I can output my tabs as divs
}

and calling this in this way in template.php:

/**
 * Theme function to output tablinks for classic Quicktabs style tabs.
 *
 * @ingroup themeable
 */
function mytheme_qt_quicktabs_tabset(&$vars) {
  $variables = array(
    'attributes' => array(
      'class' => 'quicktabs-tabs quicktabs-style-' . $vars['tabset']['#options']['style'],
    ),
    'items' => array(),
  );
  foreach (element_children($vars['tabset']['tablinks']) as $key) {
    $item = array();
    if (is_array($vars['tabset']['tablinks'][$key])) {
      $tab = $vars['tabset']['tablinks'][$key];
      if ($key == $vars['tabset']['#options']['active']) {
        $item['class'] = array('active');
      }
      $item['data'] = drupal_render($tab);
      $variables['items'][] = $item;
    }
  }
  //normally theme_item_list() is called: return theme('item_list', $variables);
  return theme('mymoduletabs_hook', $variables);
}

function mytheme_mymoduletabs_hook($variables){
  //here I can finally output my tabs in divs
}

It's the first time I try this approach and would appreciate feedback. The intricacy of my solution worries me a bit - am I on the right path here?

jQuery seems to be the way to go if you want to manipulate the markup output by Quicktabs.

 /*we only want to append the data once hence the condition */
 if (!($('#quicktabs-my_tabs .quicktabs-tabs li img').length > 0)) {
   $('#quicktabs-my_tabs .quicktabs-tabs li.first').prepend("");
   $('#quicktabs-my_tabs .quicktabs-tabs li.first').next().prepend("");
   $('#quicktabs-my_tabs .quicktabs-tabs li.last').prepend("");
   $('#quicktabs-my_tabs .quicktabs-tabs li a').append('');
 }

Note that this example works for 3 tabs - it should be modified for your setup.

In order to make the whole quicktab a clickable link, add appropriate css to the span inside the a element, as described in this post: Make a div into a link


Block disable but show in front page I installed a theme that come with different homepage style (homepage-2, homepage-3, etc..)

I configured a new homepage name as homepage-abc, then I set my Default front page to homepage-abc. (Configuration>Site Information)

When I checked the frontpage, it displays homepage-abc with frontpage layout.

I check these frontpage blocks, the blocks show in frontpage is disable.

Is there other place the theme author wrote a script that configure the combination blocks to define the frontpage?

It's using context to make the combination of blocks.

Admin>Structure>Context

Under Reactions, choose block and make combination.


How to get width and height of user pictures? It seems that Drupal doesn't store the width and height of uploaded user profile pictures (standard profile, not profile2).

I would like to be able to link the profile thumbnail to a larger version if the uploaded image is larger than 480 pixels.

Is that possible without jumping through too many hoops?

I can require new users to upload pictures with a minimum size but I have imported lots of profile pictures and many are smaller than 480 pixels wide or high.

You can add an image field to the user entity. Then you can create a custom field formatter that can check if images are over a certain size and display a link to the larger size if they are. Here is an article on creating a field formater in Drupal 7: http://www.computerminds.co.uk/articles/creating-new-field-formatters-drupal-7


Get the name of the uploaded file I'm completely new in using drupal 6. I was wondering if there is a way to print the name of an uploaded file in a node. Thanks for the help

Cheers

If you want to get any node data (it loads all fields image or text), you can use node_load function

function node_load

Load a node object from the database

try from devel/php by loading any node by calling print_r( node_load(1) );

now you able to fetch your uploaded image data from node object.

or

if you want to fetch any node related data while creating node, use form alters & do custom submitting handler
please refer this link


External class (migration class) not found I have a module for my migration. My .info is:

name = "Migrate from MHT"
description = "Module to migrate my old site content to Drupal 7"
package = "ZbLabs"
core = 7.x

dependencies[] = migrate

#  include the files that contain your Migrate classes
files[] = migrate_mht.migrate.inc
files[] = migrate_mht.module
files[] = migrate_mht_author.inc
files[] = migrate_mht_author_update.inc
files[] = migrate_mht_eventi.inc

In the migrate_mht_author_update.inc I have a class with this code:

$this->map = new MigrateSQLMap($this->machineName,
  array(
    'id' => array(
      'type' => 'int',
      'not null' => TRUE,
      'description' => 'ID utente',
    )
  ),
  MhtAuthorDestination::getKeySchema()
);

The MhtAuthorDestination class is defined in "migrate_mht_author.inc" file.

class MhtAuthorDestinationMigration extends MigrateDestinationUser {

  public function __construct(array $arguments = array()) {
    dd("MhtAuthorDestinationFin __construct");
    dd($arguments);
    parent::__construct();
  }
  [....]
}

Now when I exec "drush ms" I receive this error:

Error: Class 'MhtAuthorDestination' not found in /MY/PATH/sites/all/modules/zblabs/migrate_mht/migrate_mht_author_update.inc, line 38

In "migrate_mht.migrate.inc" file I have:
function migrate_mht_migrate_api() {

 $api = array(
    'api' => 2,
    //'migrations' => array(
      //'MhtAuthorDestination' => array('class_name' => 'MhtAuthorDestination'),
    //),

  );

  return $api;
}

I have tried without comment (//) but the error remain.

Where is my error ?

The class name in your include file is MhtAuthorDestinationMigration, but you list its class name in hook_migrate_api as MhtAuthorDestination. Uncomment the line and try:

$api = array(
  'api' => 2,
  'migrations' => array(
    'MhtAuthorDestination' => array('class_name' => 'MhtAuthorDestinationMigration'),
  ),
);

return $api;