Hi!
I'm using the version 7.x-4.x-dev. I tried to copy the template file from user_badges/templates/user_badge.tp.php into my theme, and found that it throws a bunch of Undefined index, variables and similar errors.

I was debugging a bit and found the followings:
The Entity module is enabled, and in it's entity.theme.inc there's a line:

  // Add suggestions.
  $variables['theme_hook_suggestions'][] = $entity_type;

In this case my template was used as an entity template override instead of a user-badge.tpl.php override, and variables defined in template_preprocess_user_badge() are not passed to the template.

I was able to get rid of that by changing the template file definition in user_badges_theme() from 'user_badge' => ... user-badge.tpl.php to something more specific, like

function user_badges_theme() {
  return array(
    'user_badges_user_badge' => array(
      'render element' => 'elements',
      'template' => 'templates/user-badges-user-badge',
    ),
...

I think a patch would be great for that problem. I'll post mine soon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

imre.horjan’s picture

imre.horjan’s picture

Issue summary: View changes
imre.horjan’s picture

Status: Needs work » Needs review
FileSize
1.28 KB

I forgot to refactor template_preprocess_user_badge() function, here's a fix. Maybe there's a better way of integration to the Entity module, but it works.

shabana.navas’s picture

Title: Template suggestion collition with Entity module » Template suggestion collision with Entity module

Thanks. Will take a look.

shabana.navas’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, that is the right approach.

shabana.navas’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

imre.horjan’s picture

Status: Closed (fixed) » Needs review

Some lines are not changed in the 4.x-dev version...

There are still these line in the module file:

  return array(
    'user_badge' => array(
      'render element' => 'elements',
      'template' => 'templates/user-badge',
    ),

These are changed to:

    'user_badges_user_badge' => array(
      'render element' => 'elements',
      'template' => 'templates/user-badges-user-badge',
    ),

Could you please check that?

imre.horjan’s picture

As I can see it's already commited to the repository (commit a1fffe6 - 2015.09.26. 09:16), but the packaged zip and tar.gz versions are one commit behind that at 0125443 - 2015.02.06. 09:13.

quotesBro’s picture

Status: Needs review » Fixed

2015-Feb-26 package is the patched one

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.