1
pervigilo
custom block with smarty/php having problems
  • 2006/7/26 9:08

  • pervigilo

  • Just popping in

  • Posts: 6

  • Since: 2006/6/30


I have added a custom block to my homepage, the custom block is a php file with smarty code in it. I can display the block on the homepage, but when I use a post form to go to a new page, the page is blank.

I have this is my php file, for the display of the new page:

include("./xoops/mainfile.php");
include("/home/animeimm/www/xoops/header.php");

$smarty->display('answer_single.tpl');

include("/home/animeimm/www/xoops/footer.php");

and When this triggers, nothing is displayed? I mean almost nothing, I checked the page source, and it shows the following:

< html >< body >< /body >< /html > - Minus the spaces, I put those in to by-pass the html parsing engine :)

Is there any tips you could suggest on how to get XOOPS and smarty to play nice? when I change the above code to this, it displays the template file like normal:

$smarty->display('answer_single.tpl');

And when I remove the smarty, it displays my header and footer for xoops, no problem?

Need more info, please ask :) Thanks for the help.

2
frankblack
Re: custom block with smarty/php having problems
  • 2006/7/26 9:17

  • frankblack

  • Just can't stay away

  • Posts: 830

  • Since: 2005/6/13


Unfortunately you cannot use smarty in custom blocks.

But maybe you could "abuse" a templated block of a module. I mean a block which you are not willing to use in the context of the specific module. If you are knowing smarty and php a bit this should be no problem?!

3
pervigilo
Re: custom block with smarty/php having problems
  • 2006/7/26 9:24

  • pervigilo

  • Just popping in

  • Posts: 6

  • Since: 2006/6/30


ok, I figured you couldn't, because of the problems with session management :( well, it can't be perfect, right? :)

Is there any documentation online for creating a new module?

Thanks again :)

4
McNaz
Re: custom block with smarty/php having problems
  • 2006/7/26 10:08

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


Quote:
ok, I figured you couldn't, because of the problems with session management

Actually... there might be a way.

Try this.

$page = $xoopsTpl->fetch('something.tpl');
echo 
$page;

The fetch works like display but renders the content into the $page variable. You then need to spit this out.

PS. I have not tried this but it should work.

HTH.

Cheers.

McNaz.

5
pervigilo
Re: custom block with smarty/php having problems
  • 2006/7/26 11:21

  • pervigilo

  • Just popping in

  • Posts: 6

  • Since: 2006/6/30


Quote:


$page = $xoopsTpl->fetch('something.tpl');
echo 
$page;



Tried that, no change :(

6
McNaz
Re: custom block with smarty/php having problems
  • 2006/7/26 12:41

  • McNaz

  • Just can't stay away

  • Posts: 574

  • Since: 2003/4/21


I can confirm that the following works in a block.

$xoopsTpl =& new XoopsTpl();
$test = $xoopsTpl->fetch('db:xproject_ticket_view.html');
echo 
$test;

Content Type : PHP Script.

xproject_ticket_view.html is a random template from my module. The template is then rendered in the block (minus the missing un-assigned values).

So it does work.

Cheers.

7
pervigilo
Re: custom block with smarty/php having problems
  • 2006/7/27 9:55

  • pervigilo

  • Just popping in

  • Posts: 6

  • Since: 2006/6/30


OK, I see what you are saying now, but that in the custom block... I can't do that, as I need the php in the php file I am including in my block... Let me try and explain this again:

-----------------------------------------------------------
My custom block looks like this:

include("/home/myuser/www/trivia_engine.php");

type:PHP SCRIPT

------------------------------------------------------------

The surprising thing is that this block does work, it displays my php script, but the problem is that this php script is a trivia engine, so I have a
< form > in the php script direct to another portion of the php script, and that is where I am having problems...

The php script looks like this, where I am having problems:

<? php

if (isset(SOMEVARIABLESTUFF)) {
 
//Start Smarty
if (!isset ($_SESSION)) {
        
ini_set('session.save_path', $sessions_dir);
        
session_start();
        require(
'Smarty.class.php');
        
$trivia_engine = new Smarty;

        
//assigning program directories for Smarty
        
$trivia_engine->template_dir = './templates';
        
$trivia_engine->compile_dir = './templates_c';
        
$trivia_engine->config_dir = './configs';

        
//Call the variables from config file for use in PHP script
        
$trivia_engine->config_load('trivia.conf');
        
$cfg_vars = $trivia_engine->get_config_vars();
        
extract($cfg_vars);
}

include(
"/home/myuser/www/xoops/mainfile.php");
include(
"/home/animeimm/www/xoops/header.php");

$trivia_engine->display('answer_single.tpl');

include(
"/home/animeimm/www/xoops/footer.php");

};

When I try to display this page, its blank, if I comment out the "include("/home/myuser/www/xoops/header.php");" the php shows up... if I comment out "$trivia_engine->display('answer_single.tpl');" my XOOPS page shows up, but no php stuff. I think I am going to go with what FrankBlack said, but if you have another good Idea, please submit it.

Thanks again,