Building a Community

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Building a Community

Post by vigge89 »

Right now i'm creating a community/resource site, but i've now came up that the design (code) is bad, so i'm going to create a new content-management-system or whatever you call it. but I need ideas on how to build the community, should I use template based or what do you think?
the current site's location is:
http://www.vigge.net, register and check it out

I've thought alot about it, but i can't come up with a good idea on how to build this thing.
I need ides on how to design the code, so please, give me :D
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

register just to see if you liked it is always a bad idea for getting potential members

would you pay for a pair of jeans not even knowing if you liked them...........?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

malcolm: i just wanted to link to the site, if anyone wanted to have a look, but it sounded kinda wrong when reading it :?

anyway, i thought some more, and i came up with an idea like this:

top.php (db-connection, session-handling, etc..)
header.php (top layout, menu, stats etc..)
main content
footer.php (shoutbox bottom layout)

each section has its own file, file calls top, header & footer, but contains main content.


You have any other ideas, or do you think this would be a good code-layout?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Bad. You ought to separate models and views.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

what do you mean?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

The model is the business logic, the bit that defines a bunch of (unformatted) vars for output on a page.

The view is the formatting applied to the vars (html, xml, pdf etc).

Keep html out of your php scripts. Instead, create html templates with some embedded echo calls. Include the template to print the page.

It's good that you're thinking how to share some common bits like the header though.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

i've never built template-based systems before, so I would appreciate (mispelled?) some advises, tips, and anything else :D .

this is how my current template looks like:

Code: Select all

<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Strict//EN'>
<HTML>
<HEAD>
<title>&#123;title&#125;</title>
<link rel='stylesheet' href='skins/&#123;stylesheet&#125;'>
&#123;head_section&#125;
</HEAD>
<BODY OnLoad='start_clock()'>

<table align='center' border='0' cellspacing='10' cellpadding='0'>
<tr>

&#123;left&#125;

<td>
<table class='content_tbl' align='center' cellspacing='2' width='300' cellpadding='1'>

<tr>
	<td class='titlebar' colspan='10'>
	&#123;titlebar&#125;
	</td>
</tr>

<tr>
	<td colspan='10'>
	&#123;section_head&#125;
	</td>
</tr>

&#123;main&#125;

</table>
</td>

&#123;right&#125;

</tr>
</table>

</BODY>
</HTML>
title: title of the page
head-section: if meta-refreshes or anything else is used, this is the placeholder
left: menu, stats, current time etc.
titlebar: titlebar, contains $usr@keeper
section-head: sections name, and eventually message
main: main content part
right: shoutbox
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I might have misunderstood you.

You mentioned above that header.php contains layout. I assumed that meant you had one php script which contained the header model as well as html & code to print it all.

The template you posted is exactly the kind of thing I meant: ie an html file which you can edit in any wsiwyg editor. Instead of embedded echo statements, you've got placeholders.

Personally I don't bother with placeholders to save on the parsing overhead. However, like most theoretical issues to do with efficiency, it's unlikely to be significant.

The advantage of placeholders is, if you need to restrict access to parts of the app on a need to know basis, you can prevent rogue designers from trying to insert php code rather than the verbose Dreamweaver html they get paid for.
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

well, right now im not using any template-based-system, but I've made the template already, becuase i was thinking of using it.

maybe i should use php's echo-statements, becuase i think that would be easier as long as i'm the only one who have access to the code (its for my site, im not going to release the code to the public).

should is use the metod like:
1: start session & database connection
2: do all the database loading & saving
3: create the output for the page (variables or anything)
4: output it using output.php as template
what do you think about this?

edit: btw, are there any PHPDN irc channels?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Yes that sounds good.

The way I approach this is to create three distinct stages:

(1) pre client-output tasks
(2) create and send the client output
(3) post client-output tasks

Your design ought to allow you to slot in whatever pre/post tasks are required for specific pages (authentication, email notification, form procesing etc).

The client output shouldn't be bound to a single http request. For example, with submitted form data, you might want to send a redisplayed form (with previously entered values), or one of a range of messages "your post has been added to the database" or "could not update the database" or "you do not have the post privilege" etc.

Something, somewhere in the pre client-output stage would decide which client page to serve up.
jason
Site Admin
Posts: 1767
Joined: Thu Apr 18, 2002 3:14 pm
Location: Montreal, CA
Contact:

Post by jason »

Keys to creating a community.

1. Use as many existing tools as possible. They may not be "exactly" what you are looking for, but for the most part, they will work. When you have to develop the tools for your community, you will most likely spend more time building these tools rather than building your community.

2. Make access to the community as easy as possible. Signup forms suck. They really do. Most people don't want to waste time signing up for a site. If you require a signup to get into your site, you won't have a community, or it will take a LONG LONG LONG time to get one.

3. A community site takes a LONG time to build up anyways. If you aren't planning to have this be around for more than a couple years, you might as well just stop now. We've been around since 2002, and relatively speaking, we are still a small community (okay, we are probably more a medium sized community, maybe like medium-small, or something like that).

4. An effecitve community site can't be built without community involvement. Statements like " (its for my site, im not going to release the code to the public). " this early in the game do not sound good. Yeah, these forums are technically mine, in so much as I handle the hosting (via ImHosted), I take care of the domain name, I keep the site moving steadily forward. If I wanted, I could take down these forums, and no one could do anything about it.

But see, that's the ironic part. The PHPDN community isn't mine. It's a community website, and hence, it belongs to the community. I am basically the guy the keeps the plumbing in order, and everyone else is having a good time. I couldn't shut down the community, because I don't own the community.

The whole point is you don't build a community site, a community adopts your site for their community. You just happen to have the first user ID. =)
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

well, maybe the community part i said is wrong, becuase it's not a real community, i'm doing a web-resource site (remotely hosted scripts, notepad, uploader etc.), so signing up is required.
also, the community part was just me(a)nt to be a forum, shoutbox, pm system and anything else i came up with...

But anyway, thanks for replying to my topic with a long post ( :P ), I learned some from reading it :D


"On-topic" now:
So, if i use the template-based system, how would i do the outputting the "best" and most easiest way, should i use classes (which i don't have any knowledge of), or should i just use something like:

creating the client output:
$main-content = "
Hello!<br />
Welcome to bla bla bla<br />
<a href='link.php'>somelink</a><br />
";

outputting:
<html>
<body>
<?php echo $output ?>
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

anyone?
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

I favor classes for something of this size.
Post Reply