Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:00:27+00:00 2026-05-24T22:00:27+00:00

This is the issue. I have a block called ‘User Favorites Block’ It’s placed

  • 0

This is the issue.

I have a block called ‘User Favorites Block’
It’s placed in the region ‘First Sidebar’
‘First Sidebar’ appears on the front-page.
The function is supposed to grab the data from the f25_favorites table and list them inside the block. Right now the table is an empty array.
When I return $output, none of my divs or anything are output.
When I do print($output), everything is displayed.

This is my test code to show that my ‘if’ statement is returning true. http://d.pr/zDph

/*
 * f25_favorites_my_favorites theme
 */
function theme_f25_favorites_my_favorites($mypaths) {
  dsm($mypaths);
  print_r(count($mypaths));
  $output .= 'n<div id="f25-favorites">n';
    $output .= '<div id="f25-favorites-list">n';
      if (count($mypaths) == 0) {
        $output .= "No favorites have been added";
        print "No favorites have been added";
      }
      else {
        foreach ($mypaths as $indpath) {
          $output .= l($indpath->title, $indpath->path, $attributes = array());
        }
      }
    $output .= '</div>n';
    $output .= '<div id="f25-favorites-add">n';
    $output .= '</div>n';
  $output .= 'n</div>n';
  return $output;
}

This outputs this: http://d.pr/Uhrs
IF test

Note the 0 on the top left, that’s the output of the ‘count()’
And the print of the text within the ‘if’

So, this is my theme:

/*
 * f25_favorites_my_favorites theme
 */
function theme_f25_favorites_my_favorites($mypaths) {
  /*dsm($mypaths);
  print_r(count($mypaths));*/
  $output .= '\n<div id="f25-favorites">\n';
    $output .= '<div id="f25-favorites-list">\n';
      if (count($mypaths) == 0) {
        $output .= "No favorites have been added";
      }
      else {
        foreach ($mypaths as $indpath) {
          $output .= l($indpath->title, $indpath->path, $attributes = array());
        }
      }
    $output .= '</div>\n';
    $output .= '<div id="f25-favorites-add">\n';
    $output .= '</div>\n';
  $output .= '\n</div>\n';
  return $output;
}

It’s called with this hook_theme() function:

/*
 * Implentation of hook_theme().
 */
function f25_favorites_theme () {
  return array(
    'f25_favorites_my_favorites' => array (
    'arguments' => array ('mypaths' => array())
   ),
  );
}

Which is called with this hook_block() function:

/*
 * Implementation of hook_block().
 *
 */
function f25_favorites_block($op = 'list', $delta = 0, $edit = array()) {
  if ($op == 'list') {
    $blocks = array();
    $blocks['f25-favorites'] = array(
      'info' => t('User Favorites Block'),
      'cache' => BLOCK_NO_CACHE,
    );
    return $blocks;
  }

  if ($op == 'view') {
    switch ($delta) {
      case 0:
        $mypaths = f25_favorites_user_favorites();
        $block = array(
          'subject' => t('User Favorites Block'),
          'content' => theme_f25_favorites_my_favorites($mypaths)
        );
      return $block;
    };
  }
}

Noteworthy

My theme is a ‘Sub-theme’ of a theme called ‘Zen’
Zen has a block.tpl.php which looks like this: http://d.pr/AaO1

Here is the full code of my module: http://d.pr/cGqc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T22:00:28+00:00Added an answer on May 24, 2026 at 10:00 pm

    It could be a region-related problem. Try switching to Garland and add the block to a plain old Garland region, and see if it appears.

    If you see it in Garland then make sure your sub-theme really is defining that “First Sidebar” region and then actually printing its variable in the tpl files.

    (FWIW I tried your code on Garland and it displays the block fine.)

    Also, you might want to change your function call from:

    theme_f25_favorites_my_favorites($mypaths)
    

    to:

    theme('f25_favorites_my_favorites', $mypaths)
    

    …if you want to keep the code flexible (i.e. have Drupal call any preprocess functions and allow other people, or yourself in the future, to override the template’s output)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this issue, I'm have a user selected in LDAP through ldap search,
I've been reading similar questions to this issue and have been able to get
Ok so I've spent a couple hours trying to resolve this issue and have
I already have this issue but I cannot remember how to solved it. (I
I have this issue with ComboBox that uses IEnumerable<Brush> as ItemsSource; the problem lies
I do not currently have this issue , but you never know, and thought
I know there are tons of threads regarding this issue but I have not
Heyy can somebody help me ? i have this issue that still do know
This issue is driving me mad. I have several tables defined, and CRUD stored
I have been having this issue in iterating through an array of keys and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.