20
AAINC
Re: "Include" some php code into my theme.html
  • 2005/4/6 23:36

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18


you can call in php files in your theme from your theme directory like this.
<{include_php file="$xoops_rootpath/themes/your_theme/your_file.php"}>


This only brings the php file code into the theme.
You still need to execute it inside the theme.


An example of this is Ryuji PM hack.

this is the php file inside your theme directory.
ex_assign.php

// $Id$
// FILE        ::    ex_assign.php
// AUTHOR    ::    Ryuji AMANO 
// WEB        ::    Ryu's Planning 
//

global $xoopsUser$xoopsModule;
if (
is_object($xoopsUser)) {
    
$pm_handler =& xoops_gethandler('privmessage');

    
$criteria = new CriteriaCompo(new Criteria('read_msg'0));
    
$criteria->add(new Criteria('to_userid'$xoopsUser->getVar('uid')));
    
$this->assign("ex_new_messages"$pm_handler->getCount($criteria));
}

if ( 
is_object($xoopsModule) ) {
    
$this->assign('ex_moduledir'$xoopsModule->getVar('dirname'));
}

?>


Now to call into theme.html you place this below the body tag of the theme.html.

<{include_php file="$xoops_rootpath/themes/Your_Theme/ex_assign.php"}>


Now to execute this example of code into theme.html you use something like this inside the theme.html.

<{if $ex_new_messages 1}>
<
a href="<{$xoops_url}>/viewpmsg.php">Private Messagesa>
<{/if}>
<{if 
$ex_new_messages 0}>
<{if 
$smarty.server.SCRIPT_NAME == "/index.php"}>
<
script language="javascript" type="text/javascript">

script>
<{/if}>
<
a  href="<{$xoops_url}>/viewpmsg.php">
<
span style="color:#ff6600;"><{$ex_new_messages}>-Message(s)
span>a>
<{/if}>



Now with the above code, if you have any PM's the number of PM's will show next to the static link 'Private Messages'. A popup will also happen when you enter your index page telling you number of PM's.

I hope this example of the PM hack helps you.

PEACE

::::EDITED:::::
without the whistles and bells of the popup and link, all you have to do to execute the code in the above example is place this in the theme.html:

<{$ex_new_messages}>


21
AAINC
Re: "Include" some php code into my theme.html
  • 2005/4/7 0:14

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18


oops forgot i changed code.

Quote:
Now with the above code, if you have any PM's the number of PM's will show next to the static link 'Private Messages'.


is not true.

If no PM it says 'Private Messages' if 1 or more PM's it change to a red font that says "1-Message(s)" the number will reflect number of PM's.

22
simeon
Re: "Include" some php code into my theme.html
  • 2005/4/9 12:20

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


a special thanks to ya AAINC
this is exactly what i need.thanks very much

keep it goin

23
AAINC
Re: "Include" some php code into my theme.html
  • 2005/4/28 3:25

  • AAINC

  • Not too shy to talk

  • Posts: 121

  • Since: 2003/10/18


Glad it helped.
It did help? Did you get theme going?

I have been playing with the include_php file, off and on.
It is a fun and easy way to pull all sorts of hidden core functions through the theme. Outside function, within.

Peace

Login

Who's Online

209 user(s) are online (113 user(s) are browsing Support Forums)


Members: 0


Guests: 209


more...

Donat-O-Meter

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

Latest GitHub Commits