Welcome Guest, Not a member yet? Register   Sign In
Dynamic routing in codeigniter for cms
#1

[eluser]Ram Krishna[/eluser]
i have used the code of link dynamic routing .when i am executing the admin part of website it gives the routes.php text(routes written to file) in the top of website.It is due to including cache/routes.php file in config/routes.php.Can anybody help me?
the text shown on the top of page is
$route["home"]="website/display/1";/n$route["about_us"]="website/display/2";/n$route["page_name"]="website/display/3";/n$route["page_name"]="website/display/4";/n$route["my_target"]="website/display/5";/n$route["about_us/my_hobby.html"]="website/display/6";/n$route["my_target/how_to_be_a_good_engineer.html"]="website/display/7";/n$route["my_target/how_to_be_a_good_engineer.html/how_to_get_knowledge.html"]="website/display/8";/n$route["my_target/how_to_be_a_good_engineer.html/how_to_get_knowledge.html"]="website/display/9"; .
#2

[eluser]PhilTem[/eluser]
I think that's a problem since (from your link) the content for your cache/routes.php file doesn't start with a PHP-Indicator (i.e. '<?php') therefore your httpd/apache will interpret it as a regular html-file and outputs its content.

Just add a "<?php \n" to the beginning of $output as you write your cache/routes.php. I guess this should solve the problem.
#3

[eluser]Ram Krishna[/eluser]
Thanks you for Your response.The Problem has been solved but i have one more problem that these routings are not working.
#4

[eluser]PhilTem[/eluser]
Hey Ram,
in what respect don't the routes work? Don't they get routed or is it just some controller missing?
And where in ./application/config/routes.php did you require the file?
Did you check for errors? Sometimes using require or require_once without brackets will make it not work.

These are just some of my ideas for possible faults since your code actually looks pretty good/valid.
#5

[eluser]Ram Krishna[/eluser]
Thank you for your response. It worked.but now i have one more problem. i am trying to get the third numerical value of LHS url when the RHS url is accessed by using the uri helper by calling the function $this->uri->segment(3); .but this is returning the third segment of LHS of routing rule;
for example:- for routing rule $route[“my_target/how_to_be_a_good_engineer.html/how_to_get_knowledge.html”]=“website/display/8” i want to get segment whose value is 8 in routing rule by using $this->uri->segment(3) but this is returning "how_to_get_knowledge" .




Theme © iAndrew 2016 - Forum software by © MyBB