Very simple template parser (though just a bit better than CI's parser) |
[eluser]mvdg27[/eluser]
Hi guys, I'm currently in the final stages of building my CMS, fully based on CodeIgniter. The back-end is all done, and now my focus has shifted to the front-end. The actual website itself. For the front-end I was thinking of using a simple parser class, so users of the CMS an have easy to use pseudo-codes to incorporate in their website templates. I know that it's faster to simply use php codes, but I know my clients would feel way more comfortable using these pseudo-codes (and the client is always right, isn't it? ![]() So today I started working with CI's parser class, but unfortunately it's not as good as I expected. It works great for the real basic stuff, like inserting a the title, keywords, description, and content of the page. But that's about it. Some thing I came across: - the class can loop through an array, but doesn't work well if a key in the array also exists as a variable outside the array. This makes sense of course, but reduces the functionality. There should be an easy fix for this, I guess. - the is no support for doing an if/else - a for loop with count would be a nice extra feature Now I've searched the forums, and I know that more people feel the parser class is lacking. I've also seen there are various template classes available on the forum. However, I think none of them are using pseudo-codes. So now my question is, does anyone know of some good and simple template parsers that I might try to port to CI? I know there is Smarty, but I believe that it is way to complex for my needs. Really, I just want to provide a more simple interface to novice users. As soon as things start to become more complex, we'll be using PHP for that anyway. Does anyone have some tips for me? A template parser that can do the things I mentioned above? Thanks in advance, Michiel
[eluser]sophistry[/eluser]
just turn on short tags and tell the client you found a good template parser. i wrote the documentation for you below. :-) the syntax is very simple (and supports what you want - if and foreach)): <? to start template tag, ?> to end template tag, to display template variable use echo keyword, example: <? echo $variable ?> <? if($variable_to_test): ?> to start conditional, <? endif; ?> to end conditional, example: <? if($is_true): ?> <? foreach($list as $item): ?> to start loop, <? echo $item ?> inside loop <? endforeach; ?> to end loop in the controller...(developer will edit this) Code: function template() Code: <html>
[eluser]PrashantKabade[/eluser]
hey I am also facing same situation But now I came to conclusion that use smarty whenever u need and use default parser class There is template library available .Please check the following thread http://ellislab.com/forums/viewthread/88452 Happy coding :-) |
Welcome Guest, Not a member yet? Register Sign In |