Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Personal Class in TPL

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Oct 22, 2010 9:11 am    Post subject: Personal Class in TPL Reply with quote

Hello,

In TPL, how it uses a class personal ?

Exemple :
<?php
exho text::p('test');
?>

Tanks.
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Oct 22, 2010 2:10 pm    Post subject: Reply with quote

Static class access is much like in PHP.

Code:
{text::p('test')}
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Oct 22, 2010 3:03 pm    Post subject: Reply with quote

No work

PHP Fatal error: Class 'p' not found

In php, work.

PS :

My classes are automatically loaded

Code:
function __autoload($class_name) {
    require_once 'classes/' . $class_name . '.php';
}


Last edited by cobex4 on Fri Oct 22, 2010 4:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Oct 22, 2010 3:50 pm    Post subject: Reply with quote

Make sure you use Smarty 3, and your autoloader plays nice with Smarty. See the notes.

http://smarty-php.googlecode.com/svn/branches/Smarty3Dev/distribution/SMARTY2_BC_NOTES
Back to top
View user's profile Send private message Visit poster's website
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Oct 22, 2010 4:21 pm    Post subject: Reply with quote

yes yes smarty 3 rc4
Back to top
View user's profile Send private message
mohrt
Administrator


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

PostPosted: Fri Oct 22, 2010 4:33 pm    Post subject: Reply with quote

did you fix your autoloader?
Back to top
View user's profile Send private message Visit poster's website
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Oct 22, 2010 4:50 pm    Post subject: Reply with quote

Code:

function __autoload($class_name) {
    require_once 'classes/' . $class_name . '.php';
}


I have this code before loading Smarty
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Fri Oct 22, 2010 4:59 pm    Post subject: Reply with quote

Don't use __autoload. You must register your autoloader with spl_autoload_register.


Code:
function myautoload($class_name) {
  if (file_exists('classes/' . $class_name . '.php') {
       require_once 'classes/' . $class_name . '.php';
  } else {
      return false;
  }
}

spl_autoload_register('myautoload');
Back to top
View user's profile Send private message
cobex4
Smarty Regular


Joined: 02 Sep 2008
Posts: 74

PostPosted: Fri Oct 22, 2010 7:25 pm    Post subject: Reply with quote

Yesssss, A big big big thank you
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
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