Xuups
Get an account!     Login

Utilities

Main menu

Who's Online

24 user(s) are online (3 user(s) are browsing News)

Members: 0
Guests: 24

more...

Get Xoops

Support Xuups Project

News > Smarty plugins > Blocks (anywhere) - version 1.1 Update

Blocks (anywhere) - version 1.1 Update

Published by trabis on 2009/4/4 (60329 reads)
Here is an easy way to place a block in a theme or template.

Just upload this smarty plugin to class/smarty/xoops_plugins folder and you will be able to add a block using the following method:
<{block id=1}>


Replace '1' by the id of the block you want to display.

You can find id of block in blocks admin, just hover the mouse over block edit link and you will see something like this:

yoursite/modules/system/admin.php?fct=blocksadmin&op=edit&bid=3

This plugin respect XOOPS permissions. It will only display the block for users that are allowed to see it(as set in groups permissions).

This plugin also takes in consideration cached blocks.

Version 1.1 brings you some new cool options such as:

display = 'title' -> shows just title
display = 'none' -> renders the block but does not display it
options = 'enter|block|options' -> overwrites block default options
groups = 'enter|allowed|groups' -> overwrites block default group view permissions
cache = 3600 -> overwrite cache time(in seconds)

Code examples:
<{block id=1 display="title"}>   displays just the block title
<{block id=1}>                   displays just the block content
<{block id=7 display="none"}>    does not display nothing but executes the blockthis can go for online block or to trigger some cron block
<{block id=600 groups="0|1" cache=20}>  display block just for this 2 groups and sets a cache of 20 seconds
<{block id=600 options="100|100|s_poweredby.gif|0"}> displays block with diferent options


Usage example:
Place your 'multimenu' block in your theme.
Invisible online block that updates online users table.
Add an image gallery block inside article category page.
Add users online block into yogurt profile page
Etc...

No demo available, just try it!

Files linked to this article
File name Published on Hits
Download this file smarty_function_block_1.1_trabis.zip
2009/4/6 2287
Download this file smarty_function_block_1.0_trabis.zip
2009/4/4 1032

Rating 3.00/5
Rating: 3.0/5 (1 vote)
Votes are disable!
The comments are owned by the poster. We aren't responsible for their content.
Poster Thread
Mowaffaq
Posted: 2009/4/4 10:11  Updated: 2009/4/4 10:11
Moderator
Joined: 2008/6/2
From:
Posts: 48
 Re: Blocks (anywhere)
Very important plugin

Hope it is working with invisible blocks, because if I need to enable the block before using it by this smarty then I will get dublicated blocks in my site.
michael
Posted: 2009/4/4 10:42  Updated: 2009/4/4 10:42
Just popping in
Joined: 2009/3/20
From:
Posts: 1
 Re: Blocks (anywhere)
on my site its working with invisible blocks

thanks trabis!
trabis
Posted: 2009/4/4 15:19  Updated: 2009/4/4 15:19
Moderator
Joined: 2008/4/7
From: Portugal
Posts: 303
 Re: Blocks (anywhere)
@Mowaffaq - Yes, it doe not take in account visibility or side.

There are only 2 reasons for the block not to show:
- Not have enough privilege to see it
- Module (from which block belongs) is disable
satrebil
Posted: 2009/4/27 11:52  Updated: 2009/4/27 11:52
Just popping in
Joined: 2009/4/27
From: Barcelona, Spain
Posts: 6
 Re: Blocks (anywhere) - version 1.1 Update
Hello Trabis.

Excuse my English.

I installed the plug-in and not get it to work.

When I put a block on the theme, does not show anything more from the block added.

I enabled debug mode and gives no error.

The hack is compatible with XOOPS 2.0.28.2?

Thank you very much.

Carlos
trabis
Posted: 2009/4/27 13:53  Updated: 2009/4/27 13:53
Moderator
Joined: 2008/4/7
From: Portugal
Posts: 303
 Re: Blocks (anywhere) - version 1.1 Update
Carlos, you may speak in Spanish if you like.
Show the code you used please.
satrebil
Posted: 2009/4/27 14:21  Updated: 2009/4/27 14:21
Just popping in
Joined: 2009/4/27
From: Barcelona, Spain
Posts: 6
 Re: Blocks (anywhere) - version 1.1 Update
Hello Trabis,
I copied the file in the directory class/smarty/xoops_plugins

I have included in the theme, just after the body to test,
...
</
head>
<
body id="<{$xoops_dirname}>" class="<{$xoops_langcode}>">
<{
block id = (16)}>
    <
div id="xo-canvas">
        <
div id="xo-header">
            <!-- 
Start header -->
            <
div id="header">
...

The block 16 corresponds to module SmartLanguaje and should display the flags of the language
trabis
Posted: 2009/4/27 18:23  Updated: 2009/4/27 18:24
Moderator
Joined: 2008/4/7
From: Portugal
Posts: 303
 Re: Blocks (anywhere) - version 1.1 Update
Ok, why is the ()?

Use it this way:
<{block id=16}>
satrebil
Posted: 2009/4/27 21:05  Updated: 2011/10/2 21:12
Just popping in
Joined: 2009/4/27
From: Barcelona, Spain
Posts: 6
 Re: Blocks (anywhere) - version 1.1 Update
Hola ha sido un error.

Como me daba el error he quitado el smarty del theme y he puesto a mano el smarty en el post.
He probado de nuevo por si me habia equivocado, pero sigue igual.

Si edito el código fuente de la página, se acaba justo donde he puesto la etiqueta smarty y me aparece toda la página en blanco, ya que esta justo detras de la etiqueta body que es lo último que me aparece.

Gracias
satrebil
Posted: 2009/5/1 12:55  Updated: 2011/10/2 21:13
Just popping in
Joined: 2009/4/27
From: Barcelona, Spain
Posts: 6
 Re: Blocks (anywhere) - version 1.1 Update
Hola Trabis,

He estado investigando,
y las lineas de código que me producen el error y se queda sin generar el resto de la página son la 85 y la 104 que curiosamente tienen el mismo código:
$template->setCompileId($blockObj->getVar('dirname''n'));

He comentado estas dos lineas y el proceso finaliza y la página se acaba de crear.
El bloque en principio parace que funciona, pero no se cual es el objetivo de estas dos líneas de código y si pueden afectar en algo.
Gracias
Carlos
monika
Posted: 2009/5/16 1:14  Updated: 2009/5/16 1:14
Just popping in
Joined: 2009/3/19
From:
Posts: 7
 Re: Blocks (anywhere) - version 1.1 Update
Hi Trabis nice plugin many thanks for it.

I want to add adsense to the right block ONLY in the public-photo.php page not in the whole extgallery module pages.

Can your plugin help me do this?

I tried but i failed, please assist me.
trabis
Posted: 2009/5/17 1:26  Updated: 2009/5/17 1:26
Moderator
Joined: 2008/4/7
From: Portugal
Posts: 303
 Re: Blocks (anywhere) - version 1.1 Update
You need to tell me what you did, please post in forum please.
monika
Posted: 2009/5/24 10:28  Updated: 2009/5/24 10:28
Just popping in
Joined: 2009/3/19
From:
Posts: 7
 Re: Blocks (anywhere) - version 1.1 Update
Sorry Trabis for bothering you, I put the adsense code in a normal block and it works, i give up the hack :)

Thank you for your great hacks and support
jramos
Posted: 2009/7/14 10:16  Updated: 2009/7/14 10:20
Just popping in
Joined: 2009/7/14
From:
Posts: 1
 Re: Blocks (anywhere)
Olá trabis,

não consigo colocar o bloco no local pretendido.

em modo debug aparece o seguinte erro:

Fatal error: Call to undefined method XoopsTpl::setCompileId() in /class/smarty/xoops_plugins/function.block.php on line 85

obrigado desde já pela resposta e suporte
trabis
Posted: 2009/7/19 8:20  Updated: 2009/7/19 8:20
Moderator
Joined: 2008/4/7
From: Portugal
Posts: 303
 Re: Blocks (anywhere)
Olá! Por favor coloca a tua questão no forum. Preciso saber qual é a versão do XOOPS que usas.
Waqar
Posted: 2009/9/30 8:24  Updated: 2009/9/30 8:24
Just popping in
Joined: 2009/8/30
From:
Posts: 5
 Re: Blocks (anywhere)
Can i use a block within a block with this hack? i am creating a html block with xoops custom blocks. i want to put another block within this block using <{block id=15}> but it is only printing <{block id=15}> this.

can you tell me if i can do something like this?
i even put the smarty plugin in plugins directory i made it work on theme but not in a custom html block
 

Ajax Search


Advanced Search

Recent articles

News
My Tabs
My Comments
My Search
Dummy
Publisher
Defacer
Membership
My Points
My Inviter
Others Modules
Tools
My Pics
My Menus
Smarty plugins