Closed Thread Icon

Preserved Topic: Site organization with PHP (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=20891" title="Pages that link to Preserved Topic: Site organization with PHP (Page 1 of 1)" rel="nofollow" >Preserved Topic: Site organization with PHP <span class="small">(Page 1 of 1)</span>\

 
Skatefx
Bipolar (III) Inmate

From: Small Patch of Grass in CT
Insane since: Mar 2001

posted posted 04-30-2001 19:38

I am looking to organize my site with php. Hopefully it will make less coding for me. But the thing I am getting at is: i see a bunch of sites with urls to things such as http://www.mysite.com/articles.php?article2

i wanted to do this with my site. say make my whole article section in one php script, or however this works. can someone give me some insight into this or point me in the direction of a good tutorial?

thanks

Mike

PS i know this is a sketchy description of my goal but hopefully someone will catch my drift and point me in the right direction

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-30-2001 20:02

Well I personally believe that the best way to do this if you are using PHP is to combine it into a database. Otherwise simple use of SSI or even XSSI can do what you are looking for.

If you use PHP and a database MySQL (its close to free), you could add all your information into the database and retreive it using PHP.

If you want to store all your information in flat text files then you can use SSI to call in the content from the text file. This could be through the use of an include, or your could do this via the links and calling in a query string.

The database/PHP combo is IMO much more flexible, and in the future can allow you a lot more functionality and control, and probabally will take less time to make a script to update the database than to make a script to output text files, with effective naming conventions.

There are a ton of options here.

But from your post I do not believe you would have much knowledge in this area. I would recommend going to both mySQL.com and php.net and looking over the documentation there.

If you have basic programming know how I don't think it would be too hard for you to come up with a simple solution. If not I would recommend going out and getting a book on PHP which also talks about MySQL databases.

-mage-

Skatefx
Bipolar (III) Inmate

From: Small Patch of Grass in CT
Insane since: Mar 2001

posted posted 04-30-2001 20:16

Thanks for the reply mage, I have been looking into setting up a mySQL database for a while now. The only thing is lack of understanding. I think what I really ought to do is go out and buy a book. I have tried setting up databased through UNIX commands and that was confusing as hell. Im sure i can pick it up pretty fast, I know basic cgi and basic php but nothing much beyond that. I guess i'm just looking for a way to organize my site without doing a shitload of coding. My current site used soo much code to get so little across, this is why i am trying to find an alternative for my re-design project. oh well ill figure somethin out

Is mySQl and databases that hard?

Peace
Mike

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 04-30-2001 23:19

I think that you believe it to be more imposing than it actually is.

I just got my roomate into PHP, it only took me 8 months of coaxing. So I sent him off to PHP.net and guess what, he read the first 4 chapters, and said "Damn, this is easier than I thought it would be."

He thought that of PHP, well let me tell you, SQL and learning it, is at least 10,000 times easier.

to create a database go through mySQLadmin and create a DB a single line.

mysqladmin create [database name]

then open up mysql

mysql

then select you database

USE [database name];

then propagate it:

CREATE TABLE [tablename] ([fieldname] [type], [fieldname2] [type2]);

then just insert data:

INSERT INTO [tablename] values('[val1]','[val2]');

And bing you have your first database. Ignore the brackets they are just to delimit the values. This and the select statement are all that you really need to know to get started with a simple database, later you could utilize MIN and MAX functions where addition subtraction, but nothing is more complex than actually setting up the DB. If you get a syntax guide you will be fine.

-mage-

Skatefx
Bipolar (III) Inmate

From: Small Patch of Grass in CT
Insane since: Mar 2001

posted posted 04-30-2001 23:27

yea man I know what u mean. I tend to to make things harder than they are. lol.

thanks for the motivation

Peace
Mike

"Society, we all know that somethings wrong. And we've know it all along" -Pennywise-

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 04-30-2001 23:48

I used this scheme to build a site that was a four-level outline.

The first level was major categories, second level sub categories, third level sub-sub and 4th sub-sub-sub, I guess. The whole site is served by one script, index.php, that gets 4 variables that indicate which level of the outline you're on: http://example.com/index.php?top=2&side=1&inner=4&subinner=1
is equivalent to outline level II. A. 4. a.. are you with me?

There's a top navbar for the top level topics(hence my variable name). The marketroids wanted navigation menus in the sidebar that chnage dynamically with your location. Categories on the side menu expand when you click them to reveal the third level (inner), with subinner working the same way.

I coded it up as a table, more or less looking like this (vastly simplified, of course):

<TR><TD colspan=2><? include top.inc ?>
<TR><TD><? include side.inc ?><TD>
<? include $content.inc ?>
<TR><TD colspan=2><? include bottom.inc ?>

$content gets calculated by concatenating $top.$side.$inner.$subinner, and supplying zeroes for omitted values. There are files 1.2.0.0.inc and so on in an /include directory that are the actual content (navigation free, see). Code in the include files builds the right menu dynamically, handles mouseover actions and so on.

The real kicker: all the menus below top level are built by doing a db query, so adding new pages just entails inserting a row into the navigation table, and providing the appropriate include file. Mainenance is easy, the whole outline grows as needed, life is good.

Is that what you meant by your question?

(edit): forgot to mention, spiders often won't traverse links with ? in them, so there's a trick to make them do it if you're using Apache and mod_rewrite. If search engine placement is important to you, be prepared to use URL rewriting to make your dynamic site look static.(/edit)

foreach $dirtydiaper (@diapers) { s/$dirtydiaper/$cleandiaper/g; }

[This message has been edited by linear (edited 04-30-2001).]

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-01-2001 00:30

I'd higly take a look at phpmyadmin as well. it's extremely easy to set up and makes using a mySQL db very easy.

There are also easy installers for windows that will install PHP Apache and Mysql all in one for you.

Finally I just got a book called PHP/MySQL database applications I've actually found the examples quite usefull especially in some ways of normalizing databases etc.


Walking the Earth like Kane

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-01-2001 01:57

linear, that sounds far too cool, but you lost me about half way through. Any chance on seeing that in action somewhere, or getting a better idea of how the include and db files are set up? I know it's alot to ask, but if I get a better picture in my mind, I know I can do it.

Thanks

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-01-2001 05:05

Picture an outline with 4 levels. Every entry in the outline is both a page of the site, and a row in the site navigation table. Since the requirement was consistent (yet changing with context) navigation controls along the top and side nav bars, I chose to pass the value of each "position" or "coordinate" in the URL.

Every page has links to a) every top level category, listed across the top b) every second level category of the current top level category c) all the subsidiary third level pages under the current second level page, if you're sitting on a second level page, and d) the fourth-level subsidiaries if you're on a third level page. All that linkage is in an include file (PHP) that queries the database and computes the correct links (plus the current page link is highlighted). No links are hardcoded anywhere in the navbars. All come from 1) doing a SQL query then 2) displaying the right links for the context of the current page.

Why is it cool? There are around 240 pages to the site currently. Coding those navbars for the static version of this site would suck rocks. Done that. Like I said before, inserting a new page involves only inserting a row in tthe nav table and providing the include file. the PHP is handling all the navbar linkage. Every page in the site is pretty much that four cell table I show above, with page content in column two of row two.

Your needs of course, may vary. This was a solution based on specific requirements. Skatefx's example showed passing one parameter to the script, mine shows four, and that's really the only difference (other than my table-driven navigation scheme). I guess the moral is plot your site graph, then figure out what you may possibly add (I knew more pages and sections were coming) and pick your data model accordingly. You may find more joy using two scripts to serve your site, or whatever. PHP gives you tremendous flexibility with the include mechanism.

I am not able to show you the site, unfortunately. It's an internal use only site.

The real moral here: if you expect to have to react fluidly to changing navigation needs, consider table-driven navigation (my solution is not the only one).

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-01-2001 22:05

Thanks linear, I appreciate the extra effort. I'll have to reread your explination a couple of times so it sinks in, and play with a visual, but I think I can get it.

Thanks again

linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-02-2001 15:31

Butcher, take a look at http://www.waddell.com/ which was built with the framework I'm describing.

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-02-2001 18:10

Thanks Linear, I needed that!

I was going to hit you with a bunch of questions, but as I was rereading your earlier posts in this thread, I decided I better look the over and try to play with it before asking questions.

Thanks again for the link

Butcher

« BackwardsOnwards »

Show Forum Drop Down Menu