is it possible to load a block from the template folder

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
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
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.

--
itbegins.co.uk - Zikula Consulting

birtwistle.me.uk - Personal Blog


Please read the Support Guide
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

HammerHead

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.


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.
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
hello :)

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
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
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
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