Change what webpage URL looks like?

Okay… This is getting into the more advanced PHP coding and may require the extra work, I have heard of extra scripts to get this to work but have had no luck.

I think I sub-posted this before and couldnt get an answer for it, but got the answer to my main question, so now I need this…

I have folders, each containing different things, and these are for the Admin Control Panel.

So here’s how the folders are laid out:
applications/core/modules
applications/core/tools
applications/core/data

Now, these have sub folders for each things, and I am using this for very good organization.
The main problem, going to something like this in the acp:

http://www.site.com/admin/applications/core/modules/random.php

can look very gross. So, thought, how can I make this better. My first idea was to pack everything into a giant includes() system and use it all in index.php

But then I though it would be so much harder to disguise it all as index.php

So browsing around, I found other options. Many of you may be specialized with “Invision Power Board” the notorious forum software. Looking at there URLs, they all look like they were submitted by form, even though, they weren’t. This looks good for organizing and this is what I want to do. The only thing is, how they can do something like:

http://www.site.com/index.php?app=core&module=global&section=register for like a register link. Of course, they have the same kinda layout, I changed mine a little to be a bit cleaner like theirs.

But how would I do this, Have looked at coding and inside that file, I see this:

$this->form_code    = $this->html->form_code    = 'module=tools&section=licensekey';

But $this, form_code, etc are not listed in there, so I would have to go browsing through all the files over and over to understand how they didn’t this, can anyone help me with even a simple method to doing this?

I know this is a bit advanced, and a long post, but I wanted to be kinda clear on everything…

Thanks in advanced! -Improvizionz

Hi,

Firstly, you say the URLs can look very gross. But most people won’t be reading the source code of your webpage, they’ll just click links. So what you put out as :

<form action="AVeryLongAndUglyLookingURL" method="post">
&c. &c.

will be invisible to them.
So it’s not really clear to me why you are trying to do this ( and if you’re not trying to build a rocket when a pair of shoes will do fine ).

Still, I understand the curiosity about the URL you like better.
If you click a link which refers to:

http://www.site.com/index.php?app=core&module=global&section=register
What the script ‘index.php’ at www.site.com will receive is: ( the output of this )
[php]
$app = $_GET[‘app’];
$module = $_GET[‘module’];
$section = $_GET[‘global’];

echo “App: $app
\nModule: $module
\nSection: $section
\n”;
[/php]
From here on you can do all kinds of things with it. You can turn it into a path:
[php]
$path = “/$app/$module/$section.php”;
include( $path );
[/php]
In the case of the URL you posted you’d include the file “/core/global/register.php”.

With long lines of if-then-else trees you can use all three variables to include whatever script you want.
You can even use it to pull the next page you want to show from a database.

The one line of code you supplied from the the script is not very helpful. ‘$this’ is a special kind of variable that is used to refer to an object inside a class. ( You’re threading the realm of object oriented programming here, just so you’re aware ).
The function ‘form_code()’ is an object method. It belongs to the ‘$this’ object.

Enfin, if the last paragraph made any sense to you, say so and I’ll try to be more elaborate. If not, alas. Then it’s a new area for you and a lot of complex, beautiful and strange things await you. If you’re interested.

Yeah no,

Im some what new to PHP. But the thing about these form codes, is its not you enter the stuff into a form, you simply just click a link and it loads, and it would be so much easier for me developing my script, if I could use this method so if I develop an error in my script, I can instantly find out where that page is. You did an excellent job describing that last one, but this isn’t a form where you enter in all the data, and redefining the data over and over again for each one could conflict, unless I missed something in that reply. But, if you know how to do it like they did where you simply define what the pages URL is, that would be great. I have also heard of scripts that you put in your website and it enables you to do stuff like this. But I cant figure any of them out. But thanks for the help.

-Improvizionz

Well, I totally agree with Ojoshiro, who will care about the URL’s on the site.
First, you mentioned it was for an ADMIN panel. So, only the admin would care, and they don’t.
They have other things to worry about.

But, if you REALLY want a nice clean neat URL, use a mod-rewrite or a URL rewrite. This is done in the .htaccess file. This file just has an extension and hides from the world. It can redirect URL’ls with arguments into just more standard URL’s. Here is a link that tells you all about how to code this file… It might help…

http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html

Might help. Good luck!

Sponsor our Newsletter | Privacy Policy | Terms of Service