Help :-) , first attempt to make a block  Bottom

  • Hi,
    I try the create my first Zikula block that displays a random image from my gallery
    Whit this code:

    Code

    <?php @readfile('http://micware.nl/gallery2/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title'); ?>


    The above pice of code is from the developer , see : http://codex.gallery…:Modules:imageblock

    My PHP skills are limited but this is what I have:

    Code

    <?php
    // -----------------------------------------------------------------------------------
    /**
     * Randon external images block
      * Purpose of file: Show randon images  
      */

     // -----------------------------------------------------------------------------------
    function erandom_block()
    {
       return array(
        'module'        => 'mGallery2',
        'text_type'         => 'External_random_Block',
        'text_type_long'    => 'External_random_Block',
        'allow_multiple'    => false,
        'form_content'  => false,
        'form_refresh'  => false,
        'show_preview'  => true
        );
    }
    @readfile('http://micware.nl/gallery2/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
    ?>



    What happens! (see image) when I’m in the create a block menu the intended block/image show above my header. The block name is not visible/selectable in the block dropdown menu.

    http://www.micware.nl/images/img_block.jpg

    I looked at many other blocks but can see/find the solution

    Thx for everybody that’s helps on the forum
  • stabbing only but where are your blocks being called in the template?

    Also, are you selecting show all blocks?

    --
    [ stevencopley.com ]
  • Hehehehe, crazy first block eh? icon_razz
    Check other blocks and you'll see that you need a {$ModuleName}_{$blockName}block_display function.
    Also a {$ModuleName}_{$blockName}block_info function. An *_init function if you need a special security schema, etc... check the /system/Blocks/pnblocks files for instance.
    Basically you need a block like the text block (text.php in that folder) icon_wink

    So, the core will search in every /pnblocks modules subfolders
    and parse the information provided by the *_info function.
    If the info is Ok it'll be listed in the Block Admin Panel.

    Then, build the mGallery2_erandomblock_display($blockinfo) function
    as said, you should clone the text block and rename it to erandom.php
    put it in your mGallery2/pnblocks
    and rename the functions following the convention used
    and if you want build a permission schema for it.

    Then your output is like you've posted:

    Code

    ...
    $blockinfo['content'] = @readfile('http://micware.nl/gallery2/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
    ...


    And there's your new block icon_cool

    --
    - Mateo T. -
    Mis principios... son mis fines
  • It?s a bit better now, thanks to your help .
    Still have to find a way of positioning to output as you can see on my home page http://www.micware.nl/zikula
    I?m getting there icon_smile
  • Well, seems that the readfile funcion writes the result in the output buffer directly, so, even without have fully domain of output buffers, let's try to use the ob_* stuff.

    Try with this code in your _display function:

    Code

    ...
    ob_start();
    @readfile('http://micware.nl/gallery2/main.php?g2_view=imageblock.External&g2_blocks=randomImage&g2_show=title');
    $blockinfo['content'] = ob_get_contents();
    ob_end_clean();
    ...


    Hope it work in the first try icon_razz

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Hi Mateo,
    It's works perfectly,
    thx for de code
  • Awesome icon_cool

    BTW, the 1020px width is back in your site? it forces some horizontal scrolling...
    i prefer the 1000px and remove the #page border. Or do you want a kind of margin? try margin:10px 0; in the #page instead that border icon_wink just my taste... and my 0.02, is your site icon_wink

    --
    - Mateo T. -
    Mis principios... son mis fines

This list is based on users active over the last 60 minutes.