PEAK XOOPS - How to display blocks in appoint page in englishin japanese

How to display blocks in appoint page

  • You cannot open a new topic into this forum
  • Guests cannot post into this forum
Previous post - Next post | Parent - Children.1 .2 .3 | Posted on 2007/10/24 0:55
sugar  ÆóÅùʼ From: Taiwan  Posts: 6
Hello all
Have any ideas to setting some blocke in appoint page
like a "lastest news" block only display in "search.php" this page
or a "user profile" block only display in "userinfo.php" this page
Votes:8 Average:6.25
Previous post - Next post | Parent - Children.1 | Posted on 2007/10/24 3:57
GIJOE  ÀèǤ·³Áâ   Posts: 4110
I cannot understand what you want.

userinfo.php is an independent controller.
If you want to display it as a block, iframe will be the simplest way.
Votes:5 Average:8.00
Previous post - Next post | Parent - Children.1 | Posted on 2007/10/24 12:58 | Last modified
sugar  ÆóÅùʼ From: Taiwan  Posts: 6
I will hack xoops cube be SNS
so I wish some blocks only display in "userinfo.php" page, like "friends list" or " monthly calendar"

I already succeed this hack

STEP1.
Edit modules/system/admin/blocksadmin/blockform.php & blocksadmin.php
add $module_list[-2] = "User Page"; before $module_list[-1] = _AM_TOPPAGE;

STEP2.
Edit class/xoopsblock.php find function getAllByGroupModule and getNonGroupedBlocks change to
    function &getAllByGroupModule($groupid, $module_id=0, $special_page=0, $visible=null, $orderby='b.weight,b.bid', $isactive=1)
    {
        $db =& Database::getInstance();
        $ret = array();
        $sql = "SELECT DISTINCT gperm_itemid FROM ".$db->prefix('group_permission')." WHERE gperm_name = 'block_read' AND gperm_modid = 1";
        if ( is_array($groupid) ) {
            $sql .= ' AND gperm_groupid IN ('.implode(',', $groupid).')';
        } else {
            if (intval($groupid) > 0) {
                $sql .= ' AND gperm_groupid='.$groupid;
            }
        }
        $result = $db->query($sql);
        $blockids = array();
        while ( $myrow = $db->fetchArray($result) ) {
            $blockids[] = $myrow['gperm_itemid'];
        }
        if (!empty($blockids)) {
            $sql = 'SELECT b.* FROM '.$db->prefix('newblocks').' b, '.$db->prefix('block_module_link').' m WHERE m.block_id=b.bid';
            $sql .= ' AND b.isactive='.$isactive;
            if (isset($visible)) {
                $sql .= ' AND b.visible='.intval($visible);
            }
            $module_id = intval($module_id);
            if (!empty($module_id)) {
                $sql .= ' AND m.module_id IN (0,'.$module_id;
                if ($special_page == '1') {
                    $sql .= ',-1';
				}
                $sql .= ')';
            } else {
                if ($special_page == 1) {
                    $sql .= ' AND m.module_id IN (0,-1)';
		} elseif ($special_page == 2) {
		    $sql .= ' AND m.module_id IN (0,-2)';
                } else {
                    $sql .= ' AND m.module_id=0';
                }
            }
            $sql .= ' AND b.bid IN ('.implode(',', $blockids).')';
            $sql .= ' ORDER BY '.$orderby;
			//echo $sql;
            $result = $db->query($sql);
            while ( $myrow = $db->fetchArray($result) ) {
                $block =& new XoopsBlock($myrow);
                $ret[$myrow['bid']] =& $block;
                unset($block);
            }
        }
        return $ret;
    }
	
    function &getNonGroupedBlocks($module_id=0, $special_page=0,, $visible=null, $orderby='b.weight,b.bid', $isactive=1)
    {
        $db =& Database::getInstance();
        $ret = array();
        $bids = array();
        $sql = "SELECT DISTINCT(bid) from ".$db->prefix('newblocks');
        if ($result = $db->query($sql)) {
            while ( $myrow = $db->fetchArray($result) ) {
                $bids[] = $myrow['bid'];
            }
        }
        $sql = "SELECT DISTINCT(p.gperm_itemid) from ".$db->prefix('group_permission')." p, ".$db->prefix('groups')." g WHERE g.groupid=p.gperm_groupid AND p.gperm_name='block_read'";
        $grouped = array();
        if ($result = $db->query($sql)) {
            while ( $myrow = $db->fetchArray($result) ) {
                $grouped[] = $myrow['gperm_itemid'];
            }
        }
        $non_grouped = array_diff($bids, $grouped);
        if (!empty($non_grouped)) {
            $sql = 'SELECT b.* FROM '.$db->prefix('newblocks').' b, '.$db->prefix('block_module_link').' m WHERE m.block_id=b.bid';
            $sql .= ' AND b.isactive='.$isactive;
            if (isset($visible)) {
                $sql .= ' AND b.visible='.intval($visible);
            }
            $module_id = intval($module_id);
            if (!empty($module_id)) {
                $sql .= ' AND m.module_id IN (0,'.$module_id;
                if ($special_page == 1) {
                    $sql .= ',-1';
				}
                $sql .= ')';
            } else {
                if ($special_page == 1) {
                    $sql .= ' AND m.module_id IN (0,-1)';
		} elseif ($special_page == 2) {
		    $sql .= ' AND m.module_id IN (0,-2)';
                } else {
                    $sql .= ' AND m.module_id=0';
                }
            }
            $sql .= ' AND b.bid IN ('.implode(',', $non_grouped).')';
            $sql .= ' ORDER BY '.$orderby;
            $result = $db->query($sql);
            while ( $myrow = $db->fetchArray($result) ) {
                $block =& new XoopsBlock($myrow);
                $ret[$myrow['bid']] =& $block;
                unset($block);
            }
        }
        return $ret;
    }

STEP3.
Edit header.php find and change red color
    $xoopsblock = new XoopsBlock();
    $block_arr = array();
    if (is_object($xoopsUser)) {
        $xoopsTpl->assign(array('xoops_isuser' => true, 'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUserIsAdmin));
        if (!empty($xoopsModule)) {
            // set page title
            $xoopsTpl->assign(array('xoops_pagetitle' => $xoopsModule->getVar('name'), 'xoops_modulename' => $xoopsModule->getVar('name'), 'xoops_dirname' => $xoopsModule->getVar('dirname')));
            if (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname')) {
                $block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), $xoopsModule->getVar('mid'), 1, XOOPS_BLOCK_VISIBLE);
            } else {
                $block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), $xoopsModule->getVar('mid'), 0, XOOPS_BLOCK_VISIBLE);
            }
        } else {
            $xoopsTpl->assign('xoops_pagetitle', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES));
            if (!empty($xoopsOption['show_cblock'])) {
                $block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), 0, 1, XOOPS_BLOCK_VISIBLE);
            } else {
                //$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), 0, 0, XOOPS_BLOCK_VISIBLE);
		if (preg_match("/userinfo\.php$/i", xoops_getenv('PHP_SELF'))) {
			$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), 0, 2, XOOPS_BLOCK_VISIBLE);
		} else {
			$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, 0, 0, XOOPS_BLOCK_VISIBLE);
		}
            }
        }
    } else {
        $xoopsTpl->assign(array('xoops_isuser' => false, 'xoops_isadmin' => false));
        if (!empty($xoopsModule)) {
            // set page title
            $xoopsTpl->assign(array('xoops_pagetitle' => $xoopsModule->getVar('name'), 'xoops_modulename' => $xoopsModule->getVar('name'), 'xoops_dirname' => $xoopsModule->getVar('dirname')));
            if (preg_match("/index\.php$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname')) {
                $block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, $xoopsModule->getVar('mid'), 1, XOOPS_BLOCK_VISIBLE);
            } else {
                $block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, $xoopsModule->getVar('mid'), 0, XOOPS_BLOCK_VISIBLE);
            }
        } else {
            $xoopsTpl->assign('xoops_pagetitle', htmlspecialchars($xoopsConfig['slogan'], ENT_QUOTES));
            if (!empty($xoopsOption['show_cblock'])) {
                $block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, 0, 1, XOOPS_BLOCK_VISIBLE);
            } else {
                //$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, 0, 0, XOOPS_BLOCK_VISIBLE);
		if (preg_match("/userinfo\.php$/i", xoops_getenv('PHP_SELF'))) {
			$block_arr =& $xoopsblock->getAllByGroupModule($xoopsUser->getGroups(), 0, 2, XOOPS_BLOCK_VISIBLE);
		} else {
			$block_arr =& $xoopsblock->getAllByGroupModule(XOOPS_GROUP_ANONYMOUS, 0, 0, XOOPS_BLOCK_VISIBLE);
		}
            }
        }
    }

all done, now can setting block only display in userinfo.php
Votes:15 Average:2.00
Previous post - Next post | Parent - No child | Posted on 2007/10/25 3:33
GIJOE  ÀèǤ·³Áâ   Posts: 4110
I just know what you want.

But the way you posted does not look good.
Because you have to continue to merge the hack every updating the core.

My recommended way:
Just edit theme.html and control it by weight/title etc.
Votes:5 Average:10.00
Previous post - Next post | Parent - Children.1 | Posted on 2007/10/26 1:30 | Last modified
sugar  ÆóÅùʼ From: Taiwan  Posts: 6
Hi GIJOE
I know this hack does not look good
but this SNS plan will hack core and be a new project different xoops or xc
I like xc very much, so use xc do framework creat a new project and it can common use modules with xoops

maybe this project will name "xoops sns" or "sns cube" ^_^
Votes:6 Average:6.67
Previous post - Next post | Parent - No child | Posted on 2007/10/26 4:08
GIJOE  ÀèǤ·³Áâ   Posts: 4110
If you use XCL2.1.x, it might be the best way to create a "preload".
Votes:4 Average:10.00
Previous post - Next post | Parent - No child | Posted on 2007/10/27 12:18 | Last modified
gigamaster  »°Åù·³Áâ From: Geneva, Switzerland  Posts: 94
That's right, to extend XOOPS Cube just visit the forum "preload" there are some good examples.

Sugar, maybe you should check CubeLet which allow you to place any content any where.
So, you wont need to reinvent the wheel ?


Have Fun !
Votes:13 Average:3.85

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!