1
nickt
How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/9 8:57

  • nickt

  • Just popping in

  • Posts: 4

  • Since: 2004/4/9 8



Help,

I created a new Custom Block, and its made from PHP. When I preview this page it all looks OK. But when it is made visible I don't see any text inside the frame.
I turned on some debug logging and I see this:

Warning [Xoops] Smarty error: unable to read template resource: "db:system_dummy.html" in file class/smarty/Smarty.class.php line 1042

Sorry if this is in a FAQ, but I couldn't find it.

Kind regards

Nick


2
kahumbu
Re: How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/9 9:26

  • kahumbu

  • Documentation Writer

  • Posts: 277

  • Since: 2003/8/23


I'm not sure if these links will help, but they're worth a try:

Custom blocks
Custom Block display
Custom php in a block

3
nickt
Re: How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/10 19:02

  • nickt

  • Just popping in

  • Posts: 4

  • Since: 2004/4/9 8



OK, I read those, but nothing obvious shouted out. But it was still good reading anyway.

I decided to re-install xoops, from scratch, and here is what I managed to do.

1) Install Xoops. No problems.
2) Setup the admin account as instructed.
3) Once setup I cloned the default template. I called the new template nicks_test.
4) In preferences I selected nicks_test as the default template.
5) I manually added some new users. These are ficticious people used just for testing.
6) Installed the Forum module.
7) I then enabled the Top Posters block, and made it visible on the right hand side of my main page.
8) Then I edited the Top Posters block template. I did this because I prefer to show the avatars next to the name, not on top of the names.
So far so good.
9) Now I added a new PHP custom block. Inserting the code for the block works OK. I clicked "Preview" and made sure it looked OK.
10) Finally I made the custom block visible, and ticked the correct box in the preferences dialog.
11) Now on my main page an empty window appears where my custom block should go. The only thing I see is the window title!


Is this something to do with cloning the default template in step 3 above.

Regards

Nick

4
Mithrandir
Re: How to fix this "Warning [ Xoops] Smarty error"

Could be. Did you set the nicks_test as the template set to use?

Look in system admin -> templates and see if there is a missing template to generate.

5
kahumbu
Re: How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/11 12:54

  • kahumbu

  • Documentation Writer

  • Posts: 277

  • Since: 2003/8/23


Hi nickt,

If it's not too confidential, could you post the code that goes into the custom block? I would like test it in my home XOOPS setup. Others might want to try it too.

Thanks!

6
nickt
Re: How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/14 9:46

  • nickt

  • Just popping in

  • Posts: 4

  • Since: 2004/4/9 8



Hi,

OK, it's not confidential. I am just in doing some simple tests to investigate xoops.

Here is what I have.

1) I created a new database in ysql called "home". And in there I have a table called "motd", short for "Message of the day".
The table has one field called "message" which is a VARCHAR(128).
The idea is that a simple piece of text is displayed on the home page.

2)So, I now have a custom window in xoops, with the following text:
--- START ---
<?
mysql_connect(localhost, "my_sql_username", "my_sql_password") or die("Unable to connect");
@mysql_select_db("home") or die("Unable to select database");

$query="select * from motd";
$result = mysql_query($query);

$num=mysql_numrows($result);

$i = 0;
while($i < $num)
{
$message = mysql_result($result, $i, "message");

echo $message;
++$i;
}

mysql_close();
?>
--- END ---

As you can see, it is fairly simple.

When I click preview I see the text from the database OK, when I use it for real, on my XOOPS home page all I see is a window with a title, and an empty window. i.e. no content in the window.

I noticed that when I create the custom block I have to select "HTML" and not "PHP". If I select "PHP" then I see nothing in the previes window too!

Does this help?

I have also installed the LAMP stuff onto a different machine. It is all still the same versions of Apache, MySQL and PHP and xoops, but the system RedHat 9.
So, the problem occurs on 2 installations now.

Thanks for looking into this.

Regards

Nick

7
kahumbu
Re: How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/14 10:05

  • kahumbu

  • Documentation Writer

  • Posts: 277

  • Since: 2003/8/23


Hi Nick,

Seems I can't test it out because it's too specific for your setup. But I noticed the script tags. If you use PHP for custom blocks, you do not have to enter the <? and ?> tags. Just place the script you made inside without the tags and save it as PHP. Please try it out and see what happens.

Maybe some of the XOOPS dev/mod team can comment on connecting to MySQL from a custom block as I personally have no experience with that.

Thanks!

Mike

8
Mithrandir
Re: How to fix this "Warning [ Xoops] Smarty error"

Is it a different database from your normal XOOPS database?

If not, then you can just use
global $xoopsDB//I *think* that the code from the block is executed as a function, hence the globalization

$sql "SELECT etc.";
$result $xoopsDB->query($sql);
while (
$thisline $xoopsDB->fetchArray($result)) {
    echo 
$message;
}

Without the <?php ?> tags, as Kahumbu said.

9
nickt
Re: How to fix this "Warning [ Xoops] Smarty error"
  • 2004/4/14 19:38

  • nickt

  • Just popping in

  • Posts: 4

  • Since: 2004/4/9 8



Ahh, OK, we are getting somewhere now.

It all seems to hinge on the <? and ?> tags, as you all have stated.

What I see now is:

- If I use the <? and ?> tags and save the script as HTML, then preview works fine, but I see nothing in the window on my home page.

- If I omit the <? and ?> tags, and save it as PHP script, then both preview works and I see the correct text in my home page.


So, thanks to your clues, I can get it do what I want.

I appreciate that putting the <? and ?> tags around the script, and saving it as HTML is somewhat un-necessary, but I do feel that it is a bug that the preview works but not in the home page.
Do you agree?


Thanks for the help.
I will continue using xoops. Despite this initial setback I still have a good feeling about it.

Regards

Nick

10
Mithrandir
Re: How to fix this "Warning [ Xoops] Smarty error"

Might be - but it also might be that for some reason the preview can understand <? ?> whereas the actual block will need to have it as <?php ?> (not just <? but <?php)

Login

Who's Online

128 user(s) are online (88 user(s) are browsing Support Forums)


Members: 0


Guests: 128


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