| Author |
Include file with links to facilitate link changes? |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
Instead of having all your 'a' tags with all the links hardcoded, would it be practical include a file that has all addresses and whenever you need a link to just use the variable for the link?
as in a href='$home'
Wisdom spared is wisdom squared. |
|
| Author |
RE: Include file with links to facilitate link changes? |
AldarHawk
The Manager

Posts: 1662
Location: Canada
Joined: 26.01.06 Rank: God |
|
Why not just use a database query to do this?
|
|
| Author |
RE: Include file with links to facilitate link changes? |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
Because that would put a hellalot of pressure on the DB. And it's pointless to use a db for such a thing. I don't mean storing IDs for threads or such, I mean mostly static links such as the link to the home page or the link to the, say, about page. Using an include should save you some time.
I don't mean an include for something like a sidebar. I was asking this question originally because I'm making a website which has a changing bar.
Wisdom spared is wisdom squared. |
|
| Author |
RE: Include file with links to facilitate link changes? |
ynori7
Future Emperor of Earth

Posts: 1481
Location: #valhalla
Joined: 08.10.07 Rank: Diabolical |
|
|
ranma wrote:
Because that would put a hellalot of pressure on the DB.
No it wouldn't. Not unless you've got 100 links that need to be loaded every time the user visits a page in your domain.
Alternatively, you could use XML and PHP's XML Parser. That way you could pair the link with the name you want to give it.
|
|
| Author |
RE: Include file with links to facilitate link changes? |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
But why not just use includes?
Wisdom spared is wisdom squared. |
|
| Author |
RE: Include file with links to facilitate link changes? |
p4plus2
Member
Posts: 167
Location:
Joined: 31.03.08 Rank: God |
|
|
ranma wrote:
But why not just use includes?
You could, but sometimes the easy way is not the best way. I agree with the XML idea, it is flexible and specialized to its purpose. Using XML forces you to stick to a game plan, this means you won't be tempted to use any 'quick and easy hacks' in your include page for whatever reason. XML can also be held externally, which means if you have a second site they can share urls or you could have a site tag. With XML you would also be able to add more feature to your links, such as adding a tag that will contain styling information.
"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera
"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine |
|
| Author |
RE: Include file with links to facilitate link changes? |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
But what are the advantages of using a db?
Using includes seems like it would be more portable and need less setup.
Wisdom spared is wisdom squared. |
|
| Author |
RE: Include file with links to facilitate link changes? |
ynori7
Future Emperor of Earth

Posts: 1481
Location: #valhalla
Joined: 08.10.07 Rank: Diabolical |
|
|
ranma wrote:
But what are the advantages of using a db?
Simplicity.
Using includes seems like it would be more portable and need less setup.
Then use includes. It's your site, do what you want.
|
|
| Author |
RE: Include file with links to facilitate link changes? |
p4plus2
Member
Posts: 167
Location:
Joined: 31.03.08 Rank: God |
|
|
ranma wrote:
But what are the advantages of using a db?
Using includes seems like it would be more portable and need less setup.
The advantages are mostly the same as XML, however with a DB you don't directly see the file and its 'out of the way' so to speak. PostgreSQL has some good query analysing tools to test speed and such. In a DB you also can sort entries by page they will be used on, thus a query with a WHERE can be used so not all the links must be loaded. Below is an example table which would provide some nice functionality, but change it to how you need.
CREATE TABLE `links` (
`location` varchar(100) NOT NULL,
`style` varchar(250) NOT NULL,
`page` varchar(50) NOT NULL,
) ENGINE=InnoDB DEFAULT CHARSET=latin1
"You can't be something your not,
Be yourself by yourself
Stay away from me" ~Walk, Pantera
"Playing an acoustic guitar is like having sex with your clothes on" ~Dave Mustaine |
|
| Author |
RE: Include file with links to facilitate link changes? |
ranma
Member

Posts: 269
Location: Behind a sphere
Joined: 27.08.05 Rank: HBH Guru |
|
Okay. Thanks guys.
And @ynori7, I'm just playing the part of the person against it so I can see the advantages of using the db method.
Wisdom spared is wisdom squared. |
|