Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default a bit of php help

    Okay i got this issue were i can use php in the .tpl file like <?php if blah bla ?> but when it comes to doing my {ifogged} it does not work it show nothing like {ifogged} was not in the tpl ???

    heres my code.

    Code:
    class Page {
        var $page;
        
        function page ( $file ) 
        {
          $fd = fopen($file, 'rw');
          $buffer = fread($fd, filesize($file));
          fclose($fd);
            $this->page = $buffer;
        }
      
        function replace_tags ( $tags = array ( ) ) 
        {
            if ( sizeof( $tags ) > 0 )
            {
                foreach ( $tags as $tag => $data ) 
                {
                    $this->page = str_replace ( "{" . $tag . "}", $data, $this->page );
                }
                    
                $this->page = str_replace("{if:logged}", "<?php if ($hello == 'yes') { ?>", $this->page);
                $this->page = str_replace("{/if}", "<?php } ?>", $this->page);
            }
            else
            {
                die("No tags designated for replacement.");
            }
        }
      
        function output ( ) 
        {
            echo $this->page;
        }
        
       }

  2. #2
    Join Date
    May 2007
    Posts
    467
    Tokens
    0

    Default

    Okay i found out when i right click on the page and view page source it shows the php code its self in a purple color.... how can i make it so it will run that php and not just show it in the page source in purple and it does it even if you put the php right into the .tpl now :S

  3. #3
    Join Date
    Sep 2008
    Location
    UK
    Posts
    3,670
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by VistaBoy View Post
    Okay i found out when i right click on the page and view page source it shows the php code its self in a purple color.... how can i make it so it will run that php and not just show it in the page source in purple and it does it even if you put the php right into the .tpl now :S
    The file has to be .php if you have php inside it I think.
    Back for a while.

  4. #4
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    You idiot excellent ^_^, you should of said that you were using smarty template engine in your post VistaBoy. Unfortuantly I hate smarty so I cannot help you with this issue.

    You might not be using smarty, but tpl is the common extension name for the templates smarty uses.


    www.fragme.co = a project.

  5. #5
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    I use tpl for my own custom templating system, lol. So I don't think it's smarty.

    Oh and VistaBoy, if you want to run the PHP, I'm sure you'll need to use eval().

  6. #6
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    It just seems like a weird extension to use for a template outside of smarty from my point of view as I have always known tpl to be smarty. Every man to his own though.


    www.fragme.co = a project.

  7. #7
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    'tpl' is commonly known as a short term for template, thus why smarty use it as well as lots of other scripts/systems.

  8. #8
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    I'm not arguing that at all, im just saying "from my point of view".


    www.fragme.co = a project.

  9. #9
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    No no, I know I'm just saying

  10. #10
    Join Date
    Nov 2007
    Posts
    1,253
    Tokens
    150

    Latest Awards:

    Default

    tbh you know nothing, get out of the internetz!!!!

    [/sarcasm]


    www.fragme.co = a project.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •