Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
Extend klase

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
Tristan



Joined: 01 Aug 2006
Posts: 614
Location: Under the sky

PostPosted: 18.02.2007 11:23    Post subject: Extend klase Add user to your forum ignore list Reply with quote

Code:


  $fixpath = dirname(__FILE__);

  define ("SMARTY_DIR", "/home/kcnet/public_html/cms/smarty/");

  require_once (SMARTY_DIR."Smarty.class.php");
  $smarty = new Smarty;
  $smarty->compile_dir = "$fixpath/compile";
  $smarty->template_dir = "$fixpath/html";

class templates extends smarty{
        var $smarty;
        var $tags = array();           
        var $stringToTags = array();         
        var $inputTags = "";         
        var $inputStrings = "";       
        var $fetch = array();         
        var $options = array(parseType=>"",               
                                                templateURL=>"",         
                                                query=>"",                     
                                                dynamicVariableEnable=>0,         
                                                dynamicVariable=>0,
                                                breakToNUll=>0               
                                                );

        function startParse(){
                //rastavlja ulazne varijable u jedan niz
                $this->tags = explode(",", $this->inputTags);
                $this->stringToTags = explode(",", $this->inputStrings);
                //selektira statično ili dinamično
                switch($this->options[parseType]){
                        case "static":
                                $this->parseStatic();
                        break;
                        case "dynamic":
                                $this->parseDynamic();
                        break;
                }
        }

        function parseStatic(){
                $x = 0;
                $tag = array();
                foreach($this->tags as $this->tagsArray){
                        $this->assign($this->tagsArray, $this->stringToTags[$x]);
                        echo $this->tagsArray . "   " . $this->stringToTags[$x] . '<br /
><br />';

                        $x++;
                }

        }


Ovako, to je dio koda klase koja se zasniva na smartyu... klasa
napravi ono što treba... znači ispiše tagove i vrijednosti koje smarty
treba pridružiti... ali je problem u tome što smarty ne pridruži vrijednost kako treba.. uvijek pridruži samo prvi tag i prvu vrijednost...a
ostalo ne..
Pls Help... dal' moram nešto sa constructorom napraviti ili?

Thnx unaprijed

_________________
Carpe diem...
Back to top
View user's profile Send private message Visit poster's website
Tristan



Joined: 01 Aug 2006
Posts: 614
Location: Under the sky

PostPosted: 18.02.2007 15:59    Post subject: Add user to your forum ignore list Reply with quote

zyt, anybody?

_________________
Carpe diem...
Back to top
View user's profile Send private message Visit poster's website
retro_one



Joined: 16 Sep 2003
Posts: 880
Location: DUBRAVA.

PostPosted: 18.02.2007 18:07    Post subject: Add user to your forum ignore list Reply with quote

kak to izgleda instanciranje klase i pozivanje metode? pasteas kod, a izostavis najbitniji dio...

_________________
Just your average eccentric programmer.
Back to top
View user's profile Send private message
Tristan



Joined: 01 Aug 2006
Posts: 614
Location: Under the sky

PostPosted: 18.02.2007 18:26    Post subject: Re: Extend klase Add user to your forum ignore list Reply with quote

Code:


  $fixpath = dirname(__FILE__);

  define ("SMARTY_DIR", "/home/kcnet/public_html/cms/smarty/");

  require_once (SMARTY_DIR."Smarty.class.php");
  $smarty = new Smarty;
  $smarty->compile_dir = "$fixpath/compile";
  $smarty->template_dir = "$fixpath/html";

class templates extends smarty{
        var $smarty;
        var $tags = array();           
        var $stringToTags = array();         
        var $inputTags = "";         
        var $inputStrings = "";       
        var $fetch = array();         
        var $options = array(parseType=>"",               
                                                templateURL=>"",         
                                                query=>"",                     
                                                dynamicVariableEnable=>0,         
                                                dynamicVariable=>0,
                                                breakToNUll=>0               
                                                );

        function startParse(){
                //rastavlja ulazne varijable u jedan niz
                $this->tags = explode(",", $this->inputTags);
                $this->stringToTags = explode(",", $this->inputStrings);
                //selektira statično ili dinamično
                switch($this->options[parseType]){
                        case "static":
                                $this->parseStatic();
                        break;
                        case "dynamic":
                                $this->parseDynamic();
                        break;
                }
        }

        function parseStatic(){
                $x = 0;
                $tag = array();
                foreach($this->tags as $this->tagsArray){
                        $this->assign($this->tagsArray, $this->stringToTags[$x]);
                        echo $this->tagsArray . "   " . $this->stringToTags[$x] . '<br /
><br />';

                        $x++;
                }
   function finish(){
      $this->display($this->options[templateURL]);
   }
}

        }


Pozivanje klase...
Code:
$t  = new templates;
   $t->inputTags = "menitop, nof, rowid, meni";
   $t->inputStrings = "meni gornji" . "," . "nof" . "," . "rowid" . "," . "meni";
   $t->options[parseType] = "static";
   $t->options[templateURL] = "/home/kcnet/public_html/cms/smartyrules/html/quotes/index.htm";
   
   $t->startParse();
   $t->finish();
   


Znači lijepo on ispiše
menitop: meni gornje
nof: nof
rowid: rowid
meni: meni

al assigna zapravo samo prvu... (menitop zamijeni sa meni gornje)

_________________
Carpe diem...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
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