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


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

PostPosted: Mon Mar 14, 2005 7:04 pm    Post subject: Smarty Sample Application Reply with quote

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 Wink 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
View user's profile Send private message Visit poster's website
Abdon
Smarty Rookie


Joined: 10 Mar 2005
Posts: 5

PostPosted: Tue Mar 15, 2005 3:08 pm    Post subject: Reply with quote

You should inverse the sort. The last entry should go first.

Other than that thanks a lot Very Happy
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Mar 15, 2005 3:12 pm    Post subject: Reply with quote

I had it that way at first, but it is just a matter of preference I suppose Wink 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
View user's profile Send private message Visit poster's website
gestionti
Smarty Rookie


Joined: 02 Mar 2005
Posts: 15
Location: Gatineau, Qc, Canada

PostPosted: Tue Mar 29, 2005 1:12 am    Post subject: Reply with quote

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
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Tue Mar 29, 2005 3:26 am    Post subject: Reply with quote

someone else had that error, the query() is part of the PEAR library. Maybe it is a version difference?
Back to top
View user's profile Send private message Visit poster's website
G3mInI
Smarty n00b


Joined: 13 Apr 2005
Posts: 2

PostPosted: Wed Apr 13, 2005 9:35 am    Post subject: Reply with quote

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
View user's profile Send private message
G3mInI
Smarty n00b


Joined: 13 Apr 2005
Posts: 2

PostPosted: Wed Apr 13, 2005 9:47 am    Post subject: Reply with quote

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
View user's profile Send private message
leingbamboo
Smarty n00b


Joined: 11 May 2005
Posts: 2
Location: Bejing,China

PostPosted: Thu May 12, 2005 5:32 am    Post subject: May I have a question? Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
mohrt
Administrator


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

PostPosted: Thu May 12, 2005 1:23 pm    Post subject: Reply with quote

Quote:
Would you like tell me what 'extend' means?


http://us3.php.net/manual/en/keyword.extends.php


Last edited by mohrt on Thu May 26, 2005 1:40 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
rob ganly
Smarty Rookie


Joined: 25 May 2005
Posts: 10

PostPosted: Thu May 26, 2005 10:36 am    Post subject: Reply with quote

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
View user's profile Send private message
iwlucas
Smarty n00b


Joined: 14 Jun 2005
Posts: 4

PostPosted: Sat Sep 10, 2005 9:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3335
Location: Oldenburg, Germany

PostPosted: Sat Sep 10, 2005 10:54 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Sun Sep 11, 2005 5:23 am    Post subject: Reply with quote

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
View user's profile Send private message
iwlucas
Smarty n00b


Joined: 14 Jun 2005
Posts: 4

PostPosted: Mon Sep 12, 2005 6:09 am    Post subject: Reply with quote

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
View user's profile Send private message
kills
Smarty Elite


Joined: 28 May 2004
Posts: 493

PostPosted: Mon Sep 12, 2005 8:58 am    Post subject: Reply with quote

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
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 1, 2, 3, 4, 5  Next
Page 1 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