开发者

Edittable Template System (Like Wordpress)

Hey all, working on creating a template system for my own open source software. I want to make it completely edittable like a wordpress theme. I was wondering what the most efficient method is in terms of fwriting/fileputcontents and overall organization of how it's done?

I mean, I'm essentially taking a file say footer.php, fopen'ing it in a+ mode and putting all of it's content into a textarea. The user then edits it, and then I would clear the files contents, and write the textareas content to the same file. Then close that file.

Perhaps there's a better way of doing it, and that's my que开发者_JS百科stion :P.

Thanks.


I think it doesn't matter if you use: fopen, fwrite & fclose instead of file_put_contents (note that this is PHP5 only ;-) )

http://php.net/manual/en/function.file-put-contents.php

Note that this is only a shortcut, but I think it's better to use because your code will be cleaner.

The content of the file should you get with file_get_contents, because the fread() only gets 8192 bytes and than you must use a loop. (for more informations visit the docu. )

But here my version:

  1. file_get_contents('foo.bar'); // into a textarea
  2. retrive the new version
  3. and write the new file with file_put_contents(), the old one will be replaced.


Jeff Hubbard in Comment:

You should probably look into PHPTAL instead of trying to replicate the horribleness that is the WordPress template system. You'll thank me later.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜