1
hrac
how to get block's content
  • 2008/3/12 8:40

  • hrac

  • Quite a regular

  • Posts: 305

  • Since: 2002/7/15


Hello,

I want to get a block's content and I tried to get it with getvar('content') with a code like below, but it doesn't work. I think I'm doing it with wrong way. How should I do this?

PS: I get bid and type values are correct but content is blank.

Thanks
Hirac

<?php
    
require('../../mainfile.php');
    include_once 
XOOPS_ROOT_PATH.'/class/xoopsblock.php';
    
$bid 6;
    
$myblock = new XoopsBlock($bid);
    echo 
'bid:'.$myblock->getVar('bid').'<br>';
    echo 
'type:'.$myblock->getVar('block_type').'<br>';
    echo 
'content:'.$myblock->getVar('content''N').'<br>';
?>

2
hrac
Re: how to get block's content
  • 2008/3/12 9:26

  • hrac

  • Quite a regular

  • Posts: 305

  • Since: 2002/7/15


Now I understand better how block system works :) So changed the code as follows. But I need to combine block and template. How can I do this?

PS: $bl has correct information but I need to combine with template.

<?php
    
require('../../mainfile.php');
    include_once 
XOOPS_ROOT_PATH.'/class/xoopsblock.php';
    include_once 
XOOPS_ROOT_PATH.'/modules/system/blocks/system_blocks.php';

    
$bid 6;
    
$myblock = new XoopsBlock($bid);
    echo 
'bid:'.$myblock->getVar('bid').'<br>';
    echo 
'type:'.$myblock->getVar('block_type').'<br>';
    echo 
'template:'.$myblock->getVar('template').'<br>';
    echo 
'show:'.$myblock->getVar('show_func').'<br>';
    echo 
'content:'.$myblock->getVar('content''N').'<br>';
    
    
$a $myblock->getVar('show_func');
    
$options = .... // need to be implemented
    
$bl$a($options);
    echo 
$bl['logourl'];
?>

3
iHackCode
Re: how to get block's content

$myblock->getVar('content'.. will only work for custom blocks.

try using $myblock->buildBlock() to get the array.

Quote:
<?php
require('..\..\mainfile.php');
include_once XOOPS_ROOT_PATH.'\class\xoopsblock.php';
$bid = 6;

$myblock = new XoopsBlock($bid);
echo 'bid:'.$myblock->getVar('bid').'<br>';
echo 'type:'.$myblock->getVar('block_type').'<br>';
$blockArray = $myblock->buildBlock();
var_dump($blockArray);
?>


i'm not sure what you are doing, but this may also be interesting to you.
http://xoops.instant-zero.com/modules/news/article.php?storyid=20
CBB / LatestNews / Publisher / XM-Spotlight

(ノ◕ヮ◕)ノ*:・゚✧

4
hrac
Re: how to get block's content
  • 2008/3/13 8:24

  • hrac

  • Quite a regular

  • Posts: 305

  • Since: 2002/7/15


Your valuable information and link solved my problem :)

Thank you very much
Kind regards
Hirac

Login

Who's Online

134 user(s) are online (84 user(s) are browsing Support Forums)


Members: 0


Guests: 134


more...

Donat-O-Meter

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

Latest GitHub Commits