11
LazyBadger
Re: Include a block in a theme

It doesn't solve needed porblem
Mixing PHP and Smarty in theme - bad style of coding (from my POV), because it destroy main principle "Separation business-logic from presentation"
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

12
stefan88
Re: Include a block in a theme
  • 2005/8/2 19:34

  • stefan88

  • Community Support Member

  • Posts: 1086

  • Since: 2004/9/20


It does solve the problem (as I understand it - to have a permanent login in theme) if it works, and it does :)

As for the style I agree, but didn't have the time to do it in diferent way. I think it could be done as smarty plugin as the "loading time/number of queries" hack, but I'm new to smarty and will have to read some docs before doing it.

Stefan

BTW: the PHP code is needed to display the number of mesages in Inbox, not for the login itself, so this part could be removed ...
..

13
thoughtscape
Re: Include a block in a theme

Thanks stefan. That's a neat piece of code. I struggle with the presentation layer problem. I don't want to include PHP code in my presentation layer. But it looks like that would be the best approach to pull in the language constants that I am looking for. That's really what this is about -- I'm hard-coding a login form into my theme but I would prefer it to be language independent.

Now that I think about it....and actually look through the XOOPS code, I think that you are right about a Smarty plugin. It should be relatively easy to write one that would retrieve a template by name.

That way we could include an arbitrary block template by invoking the plugin function with the template file name -- system_block_login.html for example -- as an argument. The plugin would pull the template of that name from XOOPS and insert it.

I guess that this is something that we should be bouncing around in the Smarty Help forum.

Thanks for your suggestions.

james

14
carnuke
Re: Include a block in a theme
  • 2005/8/3 18:54

  • carnuke

  • Home away from home

  • Posts: 1955

  • Since: 2003/11/5


Check out 7dana.com they have several XOOPS themes that include login and search in their theme.html files.

.
http://houseofstrauss.co.uk Resource for alternative health and holistic lifestyle
search xoops

15
LazyBadger
Re: Include a block in a theme

No problem with embedding any block, main problem is transparent I18n'ion of included parts
Quis custodiet ipsos custodes?

Webmaster of
XOOPS2.RU
XOOPS Modules Proving Ground
XOOPS Themes Exhibition

16
shank
Re: Include a block in a theme
  • 2005/8/25 22:11

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


Quote:

LazyBadger wrote:
No problem with embedding any block, main problem is transparent I18n'ion of included parts


What is "I18n'ion"?

Stefan,

You could create a file in the class/smarty/plugins/ folder called insert.messages.php with this in it
<?
function 
smarty_insert_pms()
{
GLOBAL 
$xoopsUser;
$pm_handler =& xoops_gethandler('privmessage');
$uid $xoopsUser->getVar('uid');
$criteria = new CriteriaCompo(new Criteria('read_msg'0));
$criteria->add(new Criteria('to_userid'$uid));
$msgcount $pm_handler->getCount($criteria);
$GLOBALS['xoopsTpl']->assign('msgcount'$msgcount);
}
?>


Then erase your <!--php stuff and put in instead <{insert name="messages"}>

That would clean it up a bit.

Also, since the link is the same regardless of new messages or not and only the img, and/or alt text changes, you could put the if statement around the img tags, instead of the anchor tags, and get rid of one of those.

Like this
&nbsp;<a href="<{$xoops_url}>/viewpmsg.php">
<{if 
$msgcount 0}>
<
img src="<{$xoops_imageurl}>images/prvmsg_on.jpg" alt=You&nbsp;have&nbsp;<{$msgcount}>
&
nbsp;new&nbsp;message border="0" />
<{else}>
<
img src="<{$xoops_imageurl}>images/prvmsg_off.jpg"
 
alt="You have no new messages" border="0" /> 
<{/if}></
a>


If you want it to be gramatically correct you could add anouther if statement so that if $msgcount > 1 it says messages with an s.

That is what I did anyway.

Have fun,

Steve
s l s h a n k l e @ b e l l s o u t h . n e t

17
WarDick
Re: Include a block in a theme
  • 2005/8/26 2:26

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


This code works almost. I have been unable to get the message count to work. I must be doing something wrong. I always get a message count of zero using X.2.2.2?
Urging XOOPS to be the Best It Can Be.
Richard......

18
shank
Re: Include a block in a theme
  • 2005/8/26 3:10

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


It works in 2.0.13.1

I wil install 2.2.2on my local tomorrow and see if I can figure it out.


Stay tuned.
s l s h a n k l e @ b e l l s o u t h . n e t

19
shank
Re: Include a block in a theme
  • 2005/8/26 15:28

  • shank

  • Not too shy to talk

  • Posts: 144

  • Since: 2004/8/17


It works with multiple themes for 2.2.2 also.

What theme are you using, so I can try it with your theme.

Steve
s l s h a n k l e @ b e l l s o u t h . n e t

20
WarDick
Re: Include a block in a theme
  • 2005/8/26 16:05

  • WarDick

  • Just can't stay away

  • Posts: 890

  • Since: 2003/9/13


The default theme.

Everything works except the message count. I'll take a closer look.
Urging XOOPS to be the Best It Can Be.
Richard......

Login

Who's Online

215 user(s) are online (148 user(s) are browsing Support Forums)


Members: 0


Guests: 215


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits