Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Bottom
Get a block's placement from it's ID
  • Posted: 21.04.2006, 19:20
     
    Lobos
    rank:
    Professional Professional
    registered:
     December 2002
    Status:
    offline
    last visit:
    24.08.08
    Posts:
    1588
    I added a function to the blocks module userapi to get a blocks placement from it's id, as I didn't notice an existing way to do this...:

    Code

    /**
     * get a specific block placement
     * @author Mark West
     * @param int $args['bid'] block id
     * @return mixed item array, or false on failure
     */

    function Blocks_userapi_getplacement($args)
    {
        // Argument check
        if (!isset($args['bid']) || !is_numeric($args['bid'])) {
            pnSessionSetVar('errormsg', _MODARGSERROR);
            return false;
        }

        return DBUtil::selectObjectByID('block_placements', $args['bid'], 'bid');
    }


    Is there another way to do this? I am a little concerned at the all the DB hits I need to gather the block info, would it be better to use some type of JOIN to retrieve all the blocks data at once (ie blockinfo and placement)? It would be nice if this could be done like the Blocks_userapi_getall($args) function, but with the added placement info...

    Thanks for any advice on this...

    -Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • Posted: 27.04.2006, 21:27
     
    Lobos
    rank:
    Professional Professional
    registered:
     December 2002
    Status:
    offline
    last visit:
    24.08.08
    Posts:
    1588
    Just wondering is this type of functionality going to be added to the core blocks userapi? I ask this because I will need the function for a module I am working on - I will add the function to my modules API if this functionality will not be included...

    On another note I can't seem to use the DButil class with pn762, is this not present?

    -Lobos

    --
    -Lobos
    Professional PHP Framework Services: Concept, Development and Deployment
  • Posted: 27.04.2006, 21:30
     
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720
    Lobos,

    I'd missed this thread initially but i'll add this API and review it for performence - there may be a better way.... It's best to post patches to the patch tracker so they don't get missed in the forums.

    DBUtil is part of the Openstar object library and thus doesn't exist in .762.

    -Mark

Extensions Moderation

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula