Welcome Guest, Not a member yet? Register   Sign In
Basic index($variable) question for creating a site like www.mysite.com/username
#11

[eluser]AlanW[/eluser]
[quote author="AlanW" date="1352754869"]Thanks!

[quote author="siptik" date="1352754725"]try this:
Code:
$route[‘default_controller’] = “main”;
route $route["(:any)"] = ‘main/index/$1’
$route[‘404_override’] = ‘’;
[/quote]

Do you mean 'set route $route["(:any)"] = ‘main/index/$1’ …?

[/quote]

Actually, I wondered if you need the word 'set' … or route.

It looks like the other lines start with $route so I'll try adding:

$route["(:any)"] = ‘main/index/$1’;
#12

[eluser]siptik[/eluser]
I'm sorry that I unclear wrote
#13

[eluser]AlanW[/eluser]
Thank you all!

[quote author="siptik" date="1352754725"]try this:
Code:
$route[‘default_controller’] = “main”;
route $route["(:any)"] = ‘main/index/$1’
$route[‘404_override’] = ‘’;
[/quote]

I added this:

$route['(:any)'] = "main/index/$1";

to my routes config file.

The www.mysite.com/username is now recognized by

public function index ($username){
}

BUT my other controllers such as www.mysite.com/notitications (controller is notifications.php ) are now not functioning. I finally get it - the site now thinks that there is only one page - not my plan. Is there some way to again recognize the the other controllers?

#14

[eluser]AlanW[/eluser]
[quote author="siptik" date="1352755582"]I'm sorry that I unclear wrote[/quote]

No problem - I really appreciate the help!
#15

[eluser]siptik[/eluser]
you need to add route for each controllers
#16

[eluser]PhilTem[/eluser]
Maybe you want to have a look at this kinda tutorial I wrote some months ago for other people having the same problem:

http://files.ignitedco.de/codeigniter/tu...uting.html

It does not match your problem perfectly, but you might understand how the added route works.

BTW: Every route that you add must go after the default_controller and 404_override route. And watch out to take the correct apostrophes - PHP uses quotation marks and no apostrophes Wink
#17

[eluser]AlanW[/eluser]
[quote author="PhilTem" date="1352759915"]Maybe you want to have a look at this kinda tutorial I wrote some months ago for other people having the same problem:

http://files.ignitedco.de/codeigniter/tu...uting.html

It does not match your problem perfectly, but you might understand how the added route works.

BTW: Every route that you add must go after the default_controller and 404_override route. And watch out to take the correct apostrophes - PHP uses quotation marks and no apostrophes Wink [/quote]


I looked at your tutorial and noticed you have some constructor code. But the CI User Guide does not have the constructor at the beginning here: http://ellislab.com/codeigniter/user-gui...llers.html It does mention contractors later on but I'm not familiar enough with CI to know if the following constructor code is always required:

public function __construct()
{
parent::__construct();
}

I don't have this in my controllers…do I require it?
#18

[eluser]AlanW[/eluser]
[quote author="siptik" date="1352756469"]you need to add route for each controllers[/quote]

Can you please help me with what code I need to repeat for each controller?

#19

[eluser]AlanW[/eluser]
[quote author="AlanW" date="1352755256"][quote author="AlanW" date="1352754869"]Thanks!

[quote author="siptik" date="1352754725"]try this:
Code:
$route[‘default_controller’] = “main”;
route $route["(:any)"] = ‘main/index/$1’
$route[‘404_override’] = ‘’;
[/quote]

Do you mean 'set route $route["(:any)"] = ‘main/index/$1’ …?

[/quote]

Actually, I wondered if you need the word 'set' … or route.

It looks like the other lines start with $route so I'll try adding:

$route["(:any)"] = ‘main/index/$1’;
[/quote]


Thanks again. I am really trying to understand the (:any) piece here to get my www.mysite.com/username and also allow other controllers. It doesn't appear to me that what I want to do is an easy task. For others, I'm including this reference here:

At http://ellislab.com/codeigniter/user-gui...uting.html they describe this:

$route['product/(:any)'] = "catalog/product_lookup";
A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the "product_lookup" method.

$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";
A URL with "product" as the first segment, and a number in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.




Theme © iAndrew 2016 - Forum software by © MyBB