1
nayeem
blocks and templates
  • 2004/6/17 19:15

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


what are the major differences between blocks and templates?

2
tl
Re: blocks and templates
  • 2004/6/17 21:08

  • tl

  • Friend of XOOPS

  • Posts: 999

  • Since: 2002/6/23



3
nayeem
Re: blocks and templates
  • 2004/6/17 21:29

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


thanks but i already read this and this doesnt seem to treat blocks and templates as seperate things, instead its talking about the difference between themes and templates which is not quite what i am looking for...

4
tl
Re: blocks and templates
  • 2004/6/17 21:49

  • tl

  • Friend of XOOPS

  • Posts: 999

  • Since: 2002/6/23


Block controls what information get displayed, how the contents get displayed is up to template.

news bigstory block (news_bigstory.php)
function b_news_bigstory_show() {
    global 
$xoopsDB;
    
$myts =& MyTextSanitizer::getInstance();
    
$block = array();
    
$tdate mktime(0,0,0,date("n"),date("j"),date("Y"));
    
$result $xoopsDB->query("SELECT storyid, title 
FROM "
.$xoopsDB->prefix("stories")." WHERE published > 
"
.$tdate." AND published < ".time()." AND (expired >
 "
.time()." OR expired = 0) ORDER BY counter DESC",1,0);
    list(
$fsid$ftitle) = $xoopsDB->fetchRow($result);
    if ( !
$fsid && !$ftitle ) {
        
$block['message'] = _MB_NEWS_NOTYET;
    } else {
        
$block['message'] = _MB_NEWS_TMRSI;
        
$block['story_title'] = 
$myts->makeTboxData4Show($ftitle);
        
$block['story_id'] = $fsid;
    }
    return 
$block;
}
?>



here is how it gets displayed (news_block_bigstory.html)
<p><{$block.message}>p>

<{if 
$block.story_id != ""}>
  <
p><a href="<{$xoops_url}>/modules/news/article.php?
storyid=<
{$block.story_id}>"><{$block.story_title}>p>
<{/if}>


You can create a custom block without using a template.

5
Dave_L
Re: blocks and templates
  • 2004/6/17 21:52

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


A block is a rectangular area of content that may be configured to display on specified pages for specified user groups.

A template is a file containing Smarty code (and/or plain HTML). A template controls the presentation (appearance) of whatever content it's used to display. Some templates correspond to blocks, some correspond to the main part of a module, some (themes) control the overall page appearance. Some templates are only pieces that get included by other templates.

6
tl
Re: blocks and templates
  • 2004/6/17 21:59

  • tl

  • Friend of XOOPS

  • Posts: 999

  • Since: 2002/6/23


Thanks, Dave. Much better than I what had tried to explain.

7
nayeem
Re: blocks and templates
  • 2004/6/17 22:45

  • nayeem

  • Just popping in

  • Posts: 44

  • Since: 2004/1/3 1


thanks.

its a bit clear now. so how do these blocks gets called in the first place, eg in the news module's index page it uses several blocks (eg news_block_top) but i dont see any reference to calling those anywhere... ?

8
tl
Re: blocks and templates
  • 2004/6/17 23:52

  • tl

  • Friend of XOOPS

  • Posts: 999

  • Since: 2002/6/23


Blocks are referenced in news module's xoops_version.php file

The first two blocks of news module
// Blocks
$modversion['blocks'][1]['file'] = "news_topics.php";
$modversion['blocks'][1]['name'] = _MI_NEWS_BNAME1;
$modversion['blocks'][1]['description'] = "Shows news topics";
$modversion['blocks'][1]['show_func'] = "b_news_topics_show";
$modversion['blocks'][1]['template'] = 'news_block_topics.html';

$modversion['blocks'][2]['file'] = "news_bigstory.php";
$modversion['blocks'][2]['name'] = _MI_NEWS_BNAME3;
$modversion['blocks'][2]['description'] = "Shows most read story of the day";
$modversion['blocks'][2]['show_func'] = "b_news_bigstory_show";
$modversion['blocks'][2]['template'] = 'news_block_bigstory.html';




Login

Who's Online

448 user(s) are online (340 user(s) are browsing Support Forums)


Members: 0


Guests: 448


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits