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

Support Forum

Start ::  Zikula 1.0 Support ::  Themes and Templating ::  is it possible to load a block from the template folder

Moderated by: Support Team

Bottom
is it possible to load a block from the template folder

  • Link to this postingPosted: 28.04.2008, 01:29
    Profile Homepage
    mumuri
    rank:
    Helper Helper
    registered:
     May 2004
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    127
    hello
    i would like to know if it's possible to load a block from the theme folder ?
    i ve look at pnBlock.php and have seen this
    Code
    function pnBlockLoadAll()
    {
        static $blockdirs = array();

        // Load new-style blocks from system and modules tree
        $mods = pnModGetAllMods();

        foreach ($mods as $mod) {
            $modname = $mod['name'];
            $moddir  = DataUtil::formatForOS($mod['directory']);

            if (!isset($blockdirs[$modname])) {
                $blockdirs[$modname] = array ();
                $blockdirs[$modname][] = 'system/' . $moddir . '/pnblocks';
                $blockdirs[$modname][] = 'modules/' . $moddir . '/pnblocks';

                foreach ($blockdirs[$modname] as $dir) {
                    if (file_exists($dir) && is_dir($dir) && is_readable($dir)) {
                        $dh = opendir($dir);
                        while (($f = readdir($dh)) !== false) {
                            if (substr($f, -4) == '.php') {
                                $block = substr($f,0,-4);
                                pnBlockLoad($modname, $block);
                            }
                        }
                        closedir($dh);
                    }
                }
            }
        }

        $dir = 'config/blocks';
        if (file_exists($dir) && is_dir($dir) && is_readable($dir)) {
            $dh = opendir($dir);
            while (($f = readdir($dh)) !== false) {
                if (substr($f, -4) == '.php') {
                    $block = substr($f,0,-4);
                    pnBlockLoad('Legacy', $block);
                }
            }
            closedir($dh);
        }

        // Return information gathered
        return $GLOBALS['blocks_modules'];
    }

    the theme folder doesn't seems to be parsed (perhaps it's done in an other process), so i would like to know if it possible to load a block from a theme folder



    edited by: mumuri, Apr 27, 2008 - 12:42 PM
    -----
    4 pages of french & english Zik.1 tips
  • Link to this postingPosted: 28.04.2008, 04:46
    Profile Homepage
    nestormateo
    rank:
    Professional Professional
    registered:
     September 2006
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    1189
    I guess not,
    /config/blocks is the general place of the customized blocks
    and if you'll extract data from any module, you can also make a plugin in your theme...

    or you wanna to manage it with block positions?
    then put it in the /config/blocks folder icon_wink

    -----
    - Mateo T. -
    Mis principios... son mis fines
  • Link to this postingPosted: 29.04.2008, 22:39
    Profile Homepage
    Simon
    rank:
    Steering Committee Steering Committee
    registered:
     December 2002
    Status:
    offline
    last visit:
    01.09.08
    Posts:
    13408
    Blocks are a code thing, generally associated with modules rather than themes - if you need a theme 'block', either hard code it or use a Smarty plugin (or insert if you don't want it cached). These are both more efficient than the standard block code anyway.

    -----
    Regards,
    Simon

    itbegins.co.uk - Zikula Consulting

    Please read the Support Guide
  • Link to this postingPosted: 29.04.2008, 23:19
    Profile Homepage
    AmmoDump
    rank:
    Professional Professional
    registered:
     December 2003
    Status:
    offline
    last visit:
    04.09.08
    Posts:
    2918
    Not sure what your intent is...

    But you can create a dummy block (avec/sans title and content) in the block admin

    You can create the block in your theme folder as you would any custom block template.. and fill it with whatever you want...

    It is not elegant but it works.. icon_wink

    As long as block 'exists' you can render whatever you want inside it.. you don't have to use the recommend < - content - >



    -----
    David Pahl
    Zikula Support Team

  • Link to this postingPosted: 01.05.2008, 21:44
    Profile Homepage
    mumuri
    rank:
    Helper Helper
    registered:
     May 2004
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    127
    HammerHeadBlocks are a code thing, generally associated with modules rather than themes - if you need a theme 'block', either hard code it or use a Smarty plugin (or insert if you don't want it cached). These are both more efficient than the standard block code anyway.


    the problem is that you can't configure anything in Smarty, all constants are hard coded ( anyway that's what i ve done for the moment)

    AmmoDump Not sure what your intent is...

    my goal is to create a custom portal where all specific content are located in the theme path with custom plugins and templates (and eventually blocks) by using the template overriding properties, the goal ... easier maintenance.

    -----
    4 pages of french & english Zik.1 tips
  • Link to this postingPosted: 02.05.2008, 01:44
    Profile Homepage
    AmmoDump
    rank:
    Professional Professional
    registered:
     December 2003
    Status:
    offline
    last visit:
    04.09.08
    Posts:
    2918
    Which content?

    You can really abuse the theme system to make it do anything really. It is wonderfully powerful. Set up a few theme level variables and you can automate it to do a lot.

    Can you give a more specific example?

    Au revoir!


    -----
    David Pahl
    Zikula Support Team

  • Link to this postingPosted: 02.05.2008, 04:43
    Profile Homepage
    mumuri
    rank:
    Helper Helper
    registered:
     May 2004
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    127
    hello icon_smile

    Which content? plugins, templates and blocks (and their template)

    for instance, you ve made your own "online user" block with options that you can configure in the admin part, or you have created a block to sort news in specific ways, or you have created a block to show top member in a community

    bye



    edited by: mumuri, May 01, 2008 - 03:50 PM

    -----
    4 pages of french & english Zik.1 tips
  • Link to this postingPosted: 02.05.2008, 05:06
    Profile Homepage
    AmmoDump
    rank:
    Professional Professional
    registered:
     December 2003
    Status:
    offline
    last visit:
    04.09.08
    Posts:
    2918
    I would think that it can work, as long as you make the correct API call (if needed) you can output whatever you want, in any format you want. Xanthia is setup for pretty much full configuration, so I don't see a problem. You could even put theme checks into templates and leave them in the config file to take a more global approach.

    The flexibility is there, go crazy.

    I would love to see what you are working on, if you are willing to share.

    Later!


    -----
    David Pahl
    Zikula Support Team

  • Link to this postingPosted: 02.05.2008, 06:08
    Profile Homepage
    nestormateo
    rank:
    Professional Professional
    registered:
     September 2006
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    1189
    I guess that some little details and data can be extracted with plugins,
    some other configurable sections, can be customized blocks in the /config/blocks dir
    or in the Mumuri module icon_razz

    If there are a lot of details to control,
    theme variables list can be too large, so,
    it depends on how you order your customizations.

    As example, in BlankTheme we use three variables to control the layout, the template ("grid") to use, and the flag to use a plugin-based navigation or a block based one...

    Too complex customizations
    may requires customized blocks in the Mumuri module! icon_cool

    -----
    - Mateo T. -
    Mis principios... son mis fines
  • Link to this postingPosted: 02.05.2008, 22:53
    Profile Homepage
    mumuri
    rank:
    Helper Helper
    registered:
     May 2004
    Status:
    offline
    last visit:
    05.09.08
    Posts:
    127
    my project is a full custom template for my discussions board, for the moment i ve nothing online, but a first beta version should come soon (there is no specific module in it) (module : pnmessage, pnForum, avatar, ezcomment, autobugs ...)

    bye

Start ::  Zikula 1.0 Support ::  Themes and Templating ::  is it possible to load a block from the template folder

Main Menu

Extensions Database

Documentation

Development

Login





 


 Log in Problems?
 New User? Sign Up!

Donate to Zikula