Log in

View Full Version : Url Routing Joomla type



priya.mehta111
04-22-2010, 02:45 AM
can anyone tell me how url routing works and how to load a page as it done in joomla :)

djr33
04-22-2010, 04:04 AM
What do you mean? Can you give an example?

Generally, domain names are sent to various levels of DNS (domain name servers) until the signal reaches the host. Then the request URI (basically URL) is parsed by the server and the right page is served.

priya.mehta111
04-23-2010, 02:32 AM
hii and thank you so much for you interest
Acutally i m trying to make cms in which i would like to load the components by spliting of url and then load the components like
"index.php?option=com_content&view=section&id=4" split this url like

option=com_contents,
view=section
id=4,


it means actually the url have to load the main folder components and look for the folder content, and then look at the folder section, where it will get the code to publish my webpage content as it defined in section folders view.php;
for this example the path what script need to follow is :

joomladomain.com/components/com_content/views/section/view.html.php


see this directory if you have joomla installed on your system

bluewalrus
04-23-2010, 12:50 PM
I think thats just using php includes or requires and conditional statements for the values. http://php.net/manual/en/function.include.php http://php.net/manual/en/function.require.php

For example my page I have:


<?php
$page_sub = $_GET['sec'];
$page_on = $_GET['id'];
?>
<a href="?id=develop" <?php if ($page_on === "develop") { echo "id=\"page_on\"";}?>>Development</a>
<a href="?id=fun" <?php if ($page_on === "fun") { echo "id=\"page_on\"";}?>>Chris Activities</a>
<?php
if ($page_on === "fun") {
require("fun.php");
}
if ($page_on === "develop") {
require ("develop.php");
}
?>


domain structure:

site.com/?id=fun or site.com/index.php?id=fun

the section I have set up is used on my fun or develop section.

priya.mehta111
04-23-2010, 04:26 PM
dear i m looking to resolve the url like index.php?option=vlaue&view=solution&id=12&type=reg

like this can handle as many parameters pass to it, the content can be stored and can follow the the directory folder path which will be generate dynamically from the url or if the url is wrong or broken then it will redirect to an error page else redirect to the destination folder to load the content on the page, this is my actual problem what i want to solve. :)

bluewalrus
04-23-2010, 06:48 PM
You can do that with conditional ifs or switchs
This is a simplish break down if the domain structure were like site.com/?page=1&user=123. This is not good coding...


<?php
if (isset($_GET['page'];) {
$page_on = $_GET['page'];
if ($page_on == "1" ) {
$page_on = "home")
}
} else {
$page_on = "";
}
if (isset($_GET['user'];) {
$user = $_GET['user'];
}
?>
<h1>Welcome to the Home Page
<?php
if ($user == "123") {
?>
John.</h1>
<?php
} else {
?>
.<br /><span style="color:#ff0000;">Please login.</span></h1>
}
} else {
?>
Error Page not found.
<?php
}?>