1
T-Tech
[Solved] Smarty Help Please
  • 2004/3/15 17:01

  • T-Tech

  • Just popping in

  • Posts: 62

  • Since: 2004/3/3 1


Let's see if I can explain this without confusing anyone or myself:P

I have a theme that I need to include a php file into that holds some vars that I need to use.

Example:
(stuff.php)

sql query = $result
$result = $blah

I need to use $blah in the theme.html
So how would I include the stuff.php?????

Hope you followed that :(

2
Dave_L
Re: Smarty Help Please
  • 2004/3/15 17:32

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You can use
<{include_php file="/path/to/stuff.php"}>

but I think it needs the full path, and it might be difficult to avoid hardcoding the path within the template.

In stuff.php, the template variables could be assigned like this:

global $xoopTpl;
$xoopsTpl->assign('blah1'$blah1);
$xoopsTpl->assign('blah2'$blah2);


3
T-Tech
Re: Smarty Help Please
  • 2004/3/15 17:45

  • T-Tech

  • Just popping in

  • Posts: 62

  • Since: 2004/3/3 1


Ok, I gave that a try but it still dosent seem to be working. Below is the techtheme.php im wanting to include.

include ('../../../mainfile.php');
$prefix XOOPS_DB_PREFIX;
$dbhost XOOPS_DB_HOST;
$dbname XOOPS_DB_NAME;
$dbuser XOOPS_DB_USER;
$dbpass XOOPS_DB_PASS;
//require(XOOPS_ROOT_PATH."/class/smarty/Smarty.class.php");
//$smarty = new Smarty;
$link mysql_connect($dbhost$dbuser$dbpass);
$dbs mysql_select_db($dbname$link);
$sql mysql_query("SELECT * FROM `".XOOPS_DB_PREFIX."_themeconfig`"$link);
while( 
$row mysql_fetch_object($sql) ){
$scroll1 $row->xscroll1;
$scroll2 $row->xscroll2;
$namesite $row->xsitename;
$siteurl $row->xsiteurl;
$slogansite $row->xsiteslogan;
$copy $row->tech_copy;
$link1 "$row->link1_url">$row->link1_text";
$link2 "$row->link2_url">$row->link2_text";
$link3 "$row->link3_url">$row->link3_text";
$link4 "$row->link4_url">$row->link4_text";
$link5 "$row->link5_url">$row->link5_text";
$link6 "$row->link6_url">$row->link6_text";
$link7 "$row->link7_url">$row->link7_text";
$link8 "$row->link8_url">$row->link8_text";
$link9 "$row->link9_url">$row->link9_text";
$link10 "$row->link8_url">$row->link8_text";
global 
$xoopsTpl;
$xoopsTpl->assign("link1",$link1);
$xoopsTpl->assign("link2",link2);
$xoopsTpl->assign("link3",link3);
$xoopsTpl->assign("link4",link4);
$xoopsTpl->assign("link5",link5);
$xoopsTpl->assign("link6",link6);
$xoopsTpl->assign("link7",link7);
$xoopsTpl->assign("link8",link8);
$xoopsTpl->assign("link9",link9);
$xoopsTpl->assign("link10",link10);
$xoopsTpl->display(XOOPS_ROOT_PATH."/themes/TechThemeDefault/theme.html");
}
?>


And in the theme.html I have included this line:

<include_php file="http://mysite.com/themes/TechThemeDefault/techtheme.php" />


However, I'm still stuck :(

4
fatman
Re: Smarty Help Please
  • 2004/3/15 19:39

  • fatman

  • Friend of XOOPS

  • Posts: 176

  • Since: 2003/12/13


hmm. I would think your best approach would be to include the php file into the module index.php page rather than in the template. That would make things a little simpler.

Hope that helps you.

If you post your error messages someone might be able to give you an even better solution.

5
Mithrandir
Re: Smarty Help Please

I think including the php file on every module page, requiring this thing (or is it a site-wide thing, you want to do? In that case, include it in the root/header.php - or even better yet, make a "customincludes.php" file, which you include in the header.php and which in turn includes the file(s) you want to be included on every page. That way, you will only have to add
include (XOOPS_ROOT_PATH."/root/to/customincludes.php");

to your header.php on future XOOPS upgrades.

If you assign the variables needed as Dave wrote, and you should be able to use them in the Smarty templates.

6
T-Tech
Re: Smarty Help Please
  • 2004/3/16 0:33

  • T-Tech

  • Just popping in

  • Posts: 62

  • Since: 2004/3/3 1


*Bows to Mithrandir the trouble shooting God of xoops* lol


Mithrandir,

I took your advice on adding to the header.php, including my file to the header was not working, so I took all I needed and put it directly into the header and all is working fine. My only problem with it is that, In order for this to work on someone else's site they will have to replace the header.php they have with this modified one. Not a big deal considering its located in the main dir so they wont have a problem locating it. Regardless, your suggestion proved extremely helpful and I thank you :)

Thanks & Thanks, Danni :)

Login

Who's Online

284 user(s) are online (154 user(s) are browsing Support Forums)


Members: 0


Guests: 284


more...

Donat-O-Meter

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

Latest GitHub Commits