Not another Newb!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mrPibb
Forum Newbie
Posts: 5
Joined: Wed Mar 08, 2006 10:57 am

Not another Newb!

Post by mrPibb »

I am totally new to php, I would like to teach myself the language by jumping in head first and doing a project; but of course as a newb I dont know where to begin.

I would like to use templates and a language file much like phpBB does; that way I could change one file and have it control several others.

phpBB does something like > 'L_TOPICS' => $lang['Topics'], in the php pages and the variable is referenced from a lang_main.php file. The templages use {TOPICS} pulling again from the language file. My problem again as a newb I have not been able to decipher where and how they are calling in the info.

So I am looking for a jumpstart ... if anyone who has an extra minute or two to mentor another newbie and understands what I am attempting to accomplish could please provide me with much needed guidance I would greatly appreciate it.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This task is probably a bit, maybe more, over the head of most newbs. However if you insist, phpBB uses a variant of the Smarty template engine. The "{TOPICS}" are template variables passed in via calling one of several assignment functions that the template class provides. phpBB often calls Template::assign_vars() and Template::assign_block_vars() which fill in data for those template variables you see in the templates.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

Google "introduction tutorial php" and/or buy a good introductionary php book, like PHP for the world wide web from Larry Ulman. If you start to understand the basics, you can check out the many code examples and tutorials on these forums. Then when you start to write your own scripts, post them here and there might be people who can take a look at your code.

Good luck!

[edit:] I'm definately have to learn to type faster if I ever want to keep up with feyd :) o well, i'd better not even try :wink:
mrPibb
Forum Newbie
Posts: 5
Joined: Wed Mar 08, 2006 10:57 am

Post by mrPibb »

I figured I would get a RTFM response or two :P ...

I would much rather jump right in and start coding, I seldom read manuals, new game - play it, new desk build it, you know learn as I go. Sure I end up playing for a few more hours, or end up with spare screws, but I learn from those mistakes and the second time around I get it perfect.

Another angle of what I want to accomplish > I want to have my php filex (index.php) for example use template files (index_header.tpl) && (index_footer.tpl) etc; and have those templates reference {WORD123} {WORDXYZ} variables from a language file (mysite_language.php) ...

I shall look into this smarty engine. Thanks.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

I figured I would get a RTFM response or two
you're welcome :)

Anyway, don't forget to at least read about security issues before putting scripts on a live server. You don't want your pages be hacked/misused/etc etc
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

matthijs wrote:
I figured I would get a RTFM response or two
you're welcome :)

Anyway, don't forget to at least read about security issues before putting scripts on a live server. You don't want your pages be hacked/misused/etc etc

if you use any SQL that is passed from users,make sure you read about SQL injection. :)
mrPibb
Forum Newbie
Posts: 5
Joined: Wed Mar 08, 2006 10:57 am

Post by mrPibb »

I discovered a nice "little" class put together by Brian Lozier - its called bTemplate. It seems to do what I want, but in ~140 lines of code instead of dozens of pages like other template managers do. Very simple implementation too :D
Post Reply