Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Smarty Sample Application
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Tue Nov 22, 2011 5:55 pm    Post subject: Reply with quote

The SQL file might be amended to include an INSERT statement.

After inserting a test record the message I'm getting now is

Fatal error: Uncaught exception 'SmartyException' with message 'Unable to load template file 'guestbook.tpl'' in C:\wamp\www\sampleapp\smarty\sysplugins\smarty_internal_templatebase.php on line 127

That looks like a config error, but I'm not sure what I messed up.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7258
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 22, 2011 8:12 pm    Post subject: Reply with quote

Make sure guestbook.tpl is in the template directory and readable, and you have that directory path configured properly. You can also use $smarty->testInstall() to see if all the directories are setup correctly.
Back to top
View user's profile Send private message Visit poster's website
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Tue Nov 22, 2011 8:26 pm    Post subject: Reply with quote

In the guestbook application, where would I best place the testinstall call?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7258
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 22, 2011 8:30 pm    Post subject: Reply with quote

TheEditor wrote:
In the guestbook application, where would I best place the testinstall call?


Right after everything is setup in Smarty. On the last example, just after you initialize the extended object would do.
Back to top
View user's profile Send private message Visit poster's website
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Tue Nov 22, 2011 8:32 pm    Post subject: Reply with quote

guestbook.tpl is where I think it should be:

C:\wamp\www\sampleapp\guestbook\templates

That is the path specified in the zip file - \sampleapp\guestbook\templates\.
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7258
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 22, 2011 8:33 pm    Post subject: Reply with quote

Ah, it looks like the example is using pre Smarty 3.1 settings. Change these:

Code:
$this->template_dir = GUESTBOOK_DIR . 'templates';
      $this->compile_dir = GUESTBOOK_DIR . 'templates_c';
      $this->config_dir = GUESTBOOK_DIR . 'configs';
      $this->cache_dir = GUESTBOOK_DIR . 'cache';


to:

Code:
$this->setTemplateDir(GUESTBOOK_DIR . 'templates');
      $this->setCompileDir(GUESTBOOK_DIR . 'templates_c');
      $this->setConfigDir(GUESTBOOK_DIR . 'configs');
      $this->setCacheDir(GUESTBOOK_DIR . 'cache');
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7258
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 22, 2011 8:41 pm    Post subject: Reply with quote

sample app is updated...
Back to top
View user's profile Send private message Visit poster's website
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Tue Nov 22, 2011 8:46 pm    Post subject: Reply with quote

Ok, that seems to help things a lot. You can understand my frustration.
Back to top
View user's profile Send private message
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Tue Nov 22, 2011 9:14 pm    Post subject: Reply with quote

Ok, I've got just one more problem with the sample app. The SQL script isn't working quite right. Specifically the CREATE TABLE statement:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 8

I'm trying to get the sample app running on two separate boxes, both running identical wampserver installs. On one this works just fine. On the other I get this error.

I realize this is probably a phpMyAdmin/MySQL issue. Any ideas? Looks pretty plain vanilla stuff to me.


Last edited by TheEditor on Tue Nov 22, 2011 9:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7258
Location: Lincoln Nebraska, USA

PostPosted: Tue Nov 22, 2011 9:17 pm    Post subject: Reply with quote

TheEditor wrote:
Ok, I've got just one more problem with the sample app. The SQL script isn't working quite right. Specifically the CREATE TABLE statement:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM' at line 8

I'm trying to get the sample app running on two separate boxes, both running identical wampserver installs. On one this works just fine. On the other I get this error. I can still

I realize this is probably a phpMyAdmin/MySQL issue. Any ideas? Looks pretty plain vanilla stuff to me.


Try just removing TYPE=MyISAM, or change it to ENGINE=MyISAM. It's a mysql version issue.
Back to top
View user's profile Send private message Visit poster's website
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Tue Nov 22, 2011 9:29 pm    Post subject: Reply with quote

Ahh, that gets it. Now when I try to add an entry to the guestbook via

http://localhost/sampleapp/docs/index.php?action=add

the app throws an error

Notice: Undefined index: Name in C:\wamp\www\sampleapp\guestbook\templates_c\69c6e7be3c5be18e504253fcc3697135a767ea73.file.guestbook_form.tpl.php on line 46

Seems to be something wrong with

$_smarty_tpl->tpl_vars['post']->value['Name']

on line 46 of the template. Any ideas?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4593
Location: Hamburg / Germany

PostPosted: Tue Nov 22, 2011 10:15 pm    Post subject: Reply with quote

add
$this->error_reporting = E_ALL & ~ E_NOTICE;

to the constructor in guestbook_setup.php
Back to top
View user's profile Send private message
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Wed Nov 23, 2011 1:43 am    Post subject: Reply with quote

Now it looks like I've got a working sample app. Much thanks.

But that last bit, if I'm reading it right, just means that an error was passed over and not reported. Why was the error thrown in the first place? I'm just a newbie here, but the line looked fine.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4593
Location: Hamburg / Germany

PostPosted: Wed Nov 23, 2011 2:57 am    Post subject: Reply with quote

When the database was empty there was novalue assigned to the Smarty variable $post. Accessing {$post.Name} in the template did genearte the notice. Smarty2 did disable E_NOTICE automatically during template processing so undefined varibles have been silently ignored. In Smarty3 E_NOTICE has to be supressed by the statement to get same behaviour.

Many users and also this example does use E_NOTICE suppression as a "lazy" way to deal with unassigned variables.
Back to top
View user's profile Send private message
TheEditor
Smarty Rookie


Joined: 22 Nov 2011
Posts: 12

PostPosted: Wed Nov 23, 2011 3:09 am    Post subject: Reply with quote

Thanks much for the help. Time for me to move on to TinyMVC, and then to integrating the pair.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 4 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP