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

  • Home
  • SEARCH
  • 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 9274655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:24:15+00:00 2026-06-18T16:24:15+00:00

This is my first question on here–though I’ve used it for years for reference–so,

  • 0

This is my first question on here–though I’ve used it for years for reference–so, please forgive me if this is trivial/already answered, but I wasn’t able to find a solution.

I have a render array being returned to the ‘content’ attribute of a block view array. I’m just returning a table as of right now.

<?php
$data = array(
'#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
);

return $data;
?>

What I’d like to do is add additional markup at the beginning. I’ve tried adding a ‘#prefix’ attribute, but the results weren’t as expected; I ended up with HTML outside of the block. Anything else I thought would work seems to cause PHP errors or do nothing at all.

  • 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-06-18T16:24:16+00:00Added an answer on June 18, 2026 at 4:24 pm

    When using HTML tags with #prefix they should be closed with #suffix.
    Did you remember to close the content in #prefix?

    Like so:

    $data = array(
        '#type' => 'markup',
        '#prefix' => '<div>',
        '#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
        '#suffix' => '</div>',
    );
    

    Edit

    To control the output as HTML rather than a render array one could use the hook_block_view() hook to feed the $block[‘content’] with pure HTML rather than a render array.
    According to the documentation the $block[‘content’] can handle both types of input.

    function modulename_block_view($delta='') {
      $block = array();
    
      switch($delta) {
        case 'block_name' :
          $block['content'] = '<div>Content before</div>';
          $block['content'] .= theme('table', array('header' => $header, 'rows' => $rows));
          $block['content'] .= '<div>Content after</div>';
        break;
      }
    
      return $block;
    }
    

    If you don’t want to use the block view hook I guess you could render your render arrays in this manner instead:

    $render_array = array(
        '#type' => 'markup',
        '#markup' => theme('table', array('header' => $header, 'rows' => $rows)),
    );
    
    $before = '<div>Content before</div>';
    $after = '<div>Content after</div>';
    $data = $before.render($render_array).$after;
    return $data;
    

    See render() for a reference.
    Also remember to clear your caches like stated in this answer.

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

Sidebar

Related Questions

This is my first question here, though I'm frequent visitor. I tried to find
This is my first question here, so please try to be patient with me
Note 1: This is my first question here. Please be gentle. Note 2: Yes,
This is my first question here so please bear with me - I apologise
Greetings everyone. This is my first question here at stackoverflow so please bear with
this is my first question here so be gentle ! recently i try to
this is my first question here :) I know that I should not check
This is my first question here so try to make my best so you
Ok, I need help. This is my first question here. Background: I am working
this is my first question in here, and I would like to ask if

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.