View previous topic :: View next topic |
Author |
Message |
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Mar 14, 2005 7:04 pm Post subject: Smarty Sample Application |
|
|
There is a sample application using Smarty available on the website:
http://www.smarty.net/sampleapp1
Any comments/suggestions are welcome, as this is a work in progress Its goal is to demonstrate separation of presentation using Smarty.
Last edited by mohrt on Tue Jul 01, 2014 5:22 am; edited 1 time in total |
|
Back to top |
|
Abdon Smarty Rookie
Joined: 10 Mar 2005 Posts: 5
|
Posted: Tue Mar 15, 2005 3:08 pm Post subject: |
|
|
You should inverse the sort. The last entry should go first.
Other than that thanks a lot |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 15, 2005 3:12 pm Post subject: |
|
|
I had it that way at first, but it is just a matter of preference I suppose I wanted the first entry to show up first because it is somewhat of an intro. This is an extremely simple example, a lot of things could be done to spruce it up. |
|
Back to top |
|
gestionti Smarty Rookie
Joined: 02 Mar 2005 Posts: 15 Location: Gatineau, Qc, Canada
|
Posted: Tue Mar 29, 2005 1:12 am Post subject: |
|
|
I am trying to use your Guestbook on my machine. I get the following error :
Call to undefined function: query() in /var/www/html/Guestbook/libs/sql.lib.php on line 69, which is this line :
$this->result = $this->db->query($query);
Any suggestion? |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Mar 29, 2005 3:26 am Post subject: |
|
|
someone else had that error, the query() is part of the PEAR library. Maybe it is a version difference? |
|
Back to top |
|
G3mInI Smarty n00b
Joined: 13 Apr 2005 Posts: 2
|
Posted: Wed Apr 13, 2005 9:35 am Post subject: |
|
|
I am getting the exact same error. Same line.
Code: | Fatal error: Call to undefined method DB_Error::query() in c:\program files\apache group\Apache2\htdocs\smartyguestbook\libs\sql.lib.php on line 69
|
I am running on WinXP Corporate:
Apache- 2.0.53
PHP- 5.0.4
Pear- PEAR.php,v 1.82.2.6 2005/01/01
Smarty- $Id: Smarty.class.php,v 1.514 2005/03/22 08:45:06 messju Exp $
Any ideas on this? Are any of my versions different from what you used?
I have done other smarty tutorials and they have been successful. This however is the first tutorial that I have done which involves PEAR. In fact at first I could not just use the following:
Code: |
require('DB.php');
//I had to use absolute path like so
require('c:/php/pear/DB.php'); // PEAR DB |
Even though I did install pear as directed, and in my php.ini file, I have this line:
Code: | ; Windows: "\path1;\path2"
include_path = ".;c:/php/pear" |
Yet it would not include the file. However once I supplied an absolute path, I get the same error as what is posted above.
Yes I am very new to php and am diligently trying to learn as much as I can. If anyone has an idea as to what is wrong, please let me know. I will provide as much information as needed.
Thanks in advance,
G3mInI |
|
Back to top |
|
G3mInI Smarty n00b
Joined: 13 Apr 2005 Posts: 2
|
Posted: Wed Apr 13, 2005 9:47 am Post subject: |
|
|
You know, I am going to reply to my own question, and in only a few minutes later than I posted. Maybe this will help others with this error. I went and did a search for the error I was having in these forums and came up with someone figuring out, that the query() function was just fine, it was the information being passed to the query() function that was causing the error.
So I went and looked at guestbook_steup.php. Sure enough, like the idiot that I am, I never changed the $dsn variable information to reflect my own database name, username, and password. Once I filled in the appropriate information, that error was history!
I am finding lots of useful information in these forums. From this point on I will make more use of the search before I post.
Peace out,
G3mInI |
|
Back to top |
|
leingbamboo Smarty n00b
Joined: 11 May 2005 Posts: 2 Location: Bejing,China
|
Posted: Thu May 12, 2005 5:32 am Post subject: May I have a question? |
|
|
In the Guestbook_setup.php
You wite
class GuestBook_SQL extends SQL
Would you like tell me what 'extend' means?
Thank you |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
|
Back to top |
|
rob ganly Smarty Rookie
Joined: 25 May 2005 Posts: 10
|
Posted: Thu May 26, 2005 10:36 am Post subject: |
|
|
i'm liking the guestbook app- it has helped me lots... i have noticed however that there are not that many sample smarty apps with available source code around.
i'd love to see more to see how people have used it (from an overall architecture perspective as well as at a lower level)... i think people should be encouraged to post apps and source code where possible... i can't at the moment however as i have signed an nda! i will with my next app tho!
rob ganly |
|
Back to top |
|
iwlucas Smarty n00b
Joined: 14 Jun 2005 Posts: 4
|
Posted: Sat Sep 10, 2005 9:50 pm Post subject: |
|
|
Question: Is there a better way of looping data??
Because in this sample application, is used a while in the SQL class and then again in the template file, but this could be done with only one loop, or not?? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sat Sep 10, 2005 10:54 pm Post subject: |
|
|
iwlucas wrote: | ... but this could be done with only one loop, or not?? |
maybe it could, but that would miss the whole point of smarty.
smarty is to seperate business logic from display logic. looping over the sql result is display logic, displaying that result in a tabular fashion is display logic. |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Sun Sep 11, 2005 5:23 am Post subject: |
|
|
Hi
mohrt wrote: | someone else had that error, the query() is part of the PEAR library. Maybe it is a version difference? |
This error occurs, when dont having imported the *.sql file to the database server.
Bye,
Markus |
|
Back to top |
|
iwlucas Smarty n00b
Joined: 14 Jun 2005 Posts: 4
|
Posted: Mon Sep 12, 2005 6:09 am Post subject: |
|
|
Well, ok.. but if my application have access levels and a page, when accessed by an admin, need to have one button (if u access with another access level this button shouldtn appear)....
Whats is the best way? Make 2 pages, one for admin and another for other users or just put a {if $user eq 'admin'} in the template?? Because that is bussiness logic, isnt?
I dont know if this is the right place for this question, but i want to understand this separation of logic and presentation...
Thx |
|
Back to top |
|
kills Smarty Elite
Joined: 28 May 2004 Posts: 493
|
Posted: Mon Sep 12, 2005 8:58 am Post subject: |
|
|
Hi
iwlucas wrote: | Well, ok.. but if my application have access levels and a page, when accessed by an admin, need to have one button (if u access with another access level this button shouldtn appear)....
Whats is the best way? Make 2 pages, one for admin and another for other users or just put a {if $user eq 'admin'} in the template?? Because that is bussiness logic, isnt?
I dont know if this is the right place for this question, but i want to understand this separation of logic and presentation...
Thx |
In my opinion, you will need a smarty function for that.
{ if isAdmin() }
{/if}
Bye,
Markus |
|
Back to top |
|
|