xoops forums

lionhell

Just popping in
Posted on: 2014/8/26 0:18
lionhell
lionhell (Show more)
Just popping in
Posts: 20
Since: 2006/8/13
#1

Using variable in block title

It would be nice to have the possibility of using variables in block titles, like dates or indexes, etc ..., to have dynamic titles in blocks.

I really would appreciate to use smarty in block title !

Does someone know a hack to do that ?

Bleekk

Theme Designer
Posted on: 2014/8/26 8:47
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 934
Since: 2002/12/14
#2

Re: Using variable in block title

Every module has a template for each block. You can use smarties in the block templates.
Can you give me a example what you are trying to do (which module)

lionhell

Just popping in
Posted on: 2014/8/26 10:39
lionhell
lionhell (Show more)
Just popping in
Posts: 20
Since: 2006/8/13
#3

Re: Using variable in block title

Block templates manage block content, not block title !? Right ?

I'd like to insert smarty in the block title (not content), mainly a smarty, but any variable would be nice ...

For example:

With Birthday module, I'd like to set block title like that: "It happened on [the date]" , "the date" would be a smarty for current month and day.

I tried to enter a smarty in the xoops admin block page, but of course it didn't work

Bleekk

Theme Designer
Posted on: 2014/8/26 10:53
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 934
Since: 2002/12/14
#4

Re: Using variable in block title

Ok i understand your problem.
Your theme is displaying the block for the columns in a foreach loop.
Take a look at your theme and you will find the part <{block.title}>
to see which id your block has, add <{block.id}> behind it.

To display the date only in this block after the title you can write a if statement. Something like
<{if block.id == 3}>your date smarty<{/if}>

lionhell

Just popping in
Posted on: 2014/8/26 11:10
lionhell
lionhell (Show more)
Just popping in
Posts: 20
Since: 2006/8/13
#5

Re: Using variable in block title

So simple !? thanks trying that immediately !

But if it was possible to hack so that smarties would be granted directly in block management, it would be great, and making that change independant of theme !

lionhell

Just popping in
Posted on: 2014/8/26 11:23
lionhell
lionhell (Show more)
Just popping in
Posts: 20
Since: 2006/8/13
#6

Re: Using variable in block title

Working nicely ! Thanks ...
If you had an idea to hack xoops , well ...

Bleekk

Theme Designer
Posted on: 2014/8/26 11:31
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 934
Since: 2002/12/14
#7

Re: Using variable in block title

you are welcome :)

lionhell

Just popping in
Posted on: 2014/8/26 11:42
lionhell
lionhell (Show more)
Just popping in
Posts: 20
Since: 2006/8/13
#8

Re: Using variable in block title

Hum hum ... a tiny problem ...
I've inserted in theme.html:
<{php}>
$m['01']='janvier';
$m['02']='février';
$m['03']='mars';
$m['04']='avril';
$m['05']='mai';
$m['06']='juin';
$m['07']='juillet';
$m['08']='août';
$m['09']='septembre';
$m['10']='octobre';
$m['11']='novembre';
$m['12']='décembre';
$jour=new DateTime();
$ce_jour $jour->format('d').' '.$m[$jour->format('m')];
$xoopsTpl->assign('aujourdhui'$ce_jour);
<{/
php}>


But " $xoopsTpl->assign('aujourdhui', $ce_jour); " generates a blank page !

Bleekk

Theme Designer
Posted on: 2014/8/26 11:51
Bleekk
Bleekk (Show more)
Theme Designer
Posts: 934
Since: 2002/12/14
#9

Re: Using variable in block title

I would advise you to use smarty inside the theme.
Use smarty to create your new date variable

what you have done in php you can also do almost the same way in smarty

lionhell

Just popping in
Posted on: 2014/8/26 11:58
lionhell
lionhell (Show more)
Just popping in
Posts: 20
Since: 2006/8/13
#10

Re: Using variable in block title

The code itself is working, it's only the $xoopsTpl that is generating blank page.