Welcome Guest, Not a member yet? Register   Sign In
Best method of creating portable site links?
#1

[eluser]Bleeding Edge Productions[/eluser]
Hi guys,

What is the best way to make URLs portable in case of a page location changing and needing to update all the links on a site.

The URL helper looks like the one:
Code:
site_url(params)

Would it be good practice to set up variables in the index.php (or the default controller), like:

Code:
$url_home = 'index.php';
$url_contact = 'contact/';
$url_blog = 'personal/blog/';
$url_calendar = 'personal/calendar/main.php';

Etc. And then throughout the site when I need to create a link, I just use
Code:
<?php echo site_url($url_contact); ?>
to dynamically create the link.

Is this the most appropriate way (i.e. best practice) to go about it, or is there a better method?

Many thanks,

Martin
#2

[eluser]danbirlem[/eluser]
That's how Wordpress does it. That's the best practice I would support.
#3

[eluser]Bleeding Edge Productions[/eluser]
Thanks!




Theme © iAndrew 2016 - Forum software by © MyBB