PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1845
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Class calling itself? Posted by Sephiroth on 13 Sept 2010 at 1:18 PM
Alright, I'm developing an ultra-lightweight PHP class to parse basic XHTML templates and have hit a snag. Some of my templates include other templates to reduce file-size and repetitive code, as well as allowing things like menus to be modified by editing one single file instead of a menu on every page.

What happens is when my template-parser attempts to replace tags in a sub-template, the page never loads at all. It just completely stops working. I get nothing from the server, even if I wrap every line with "echo" statements.

Here is the function in question:
  //Public method to replace all tags on the page with their respective data
  public function ReplaceTags($Tags = array())
  {
    $SubPage = new Page(NULL);

    if(sizeof($Tags > 0))
    {
      foreach($Tags as $Tag => $Data)
      {
        //$Data = (file_exists($Data)) ? $this->Parse($Data) : $Data;
        if(file_exists($Data))
        {
          if($SubPage->LoadTemplate($Data))
          {
            if($SubPage->ReplaceTags($Tags))
              $Data = $SubPage->OutputBuffer($Data);
            else
              $Data = "<p>Failed to replace tags in template: " . $Data . "</p>";
          }
          else
            $Data = "<p>Failed to load sub-template: " . $Data . "</p>";
        } 

        $this->TempPage = eregi_replace("{" . $Tag . "}", $Data, $this->TempPage);
      }
    }
    else
      return false;

    return true;
  }

If I comment out the stuff after checking to see whether or not the file exists, everything works except sub-templates don't get parsed and as such, display funky tags instead of data. The class is called "Page".
-Sephiroth
Report
Re: Class calling itself? Posted by mac_doggie on 4 Oct 2010 at 2:51 PM
sizeof($tags > 1) should be: sizeof($tags) > 1

-mac-
mailto:mac_doggie@hotmail.com
the Netherlands...



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.