help needed about logic. |
[eluser]demiRon[/eluser]
Hi; i'm try to build new app. News Portal. i want to make a class which is complete solution for site navigation. i mean: segments -> http:/xxxxx. com/content/maincategory/subcategory Contents related with subcategory. Code: class Content extends Controller Now; i get this values; but i want to get these values at begin. i tried to move these in __constructor but i get many errors like "unexpected T_VARIABLE" Code: $cat =$this->uri->segment(2, 0); Ps: sorry for my bad eng.
[eluser]Tominator[/eluser]
Hi man! I am using CI 1.7.2: Find: Code: function __construct() Replace: Code: function Content() Now, FIND (in index() and subcat()) and DELETE: Code: $this->parser->parse('theme/'.$theme.'/cont', $data);
[eluser]demiRon[/eluser]
Thanks Tominator; it's good idea. i tried. now problem is ->http:/xxxxx. com/content/maincategory/subcategory Content ok. but it's still wants to find "maincategory" fonction. how can we make it dynamic?
[eluser]Tominator[/eluser]
Is index() your “maincategory” function. If yes add to your function Content() these line: Code: $this->index();
[eluser]demiRon[/eluser]
No, its not. But i tried, it gives twice output it looks like; Code: class Content extends Controller i think it's still tring to find maincategory segments fonc.
[eluser]Tominator[/eluser]
Yes, if you call index(), like this: http://yoursite.com/controller/index then it show it twice (because it show it in constructor and method). You can delete line: $this->index() and please answer this questions: What is your maincategory function? Where can I found it? (btw. Where are you from?)
[eluser]demiRon[/eluser]
from Turkey. Now: category table like -> id | cat_name | seo sub-category table like -> id | cat_id | acat_name | seo content table like -> id | cat_id | acat_id | txt | seo now i try to call category/sub-category so i havent to make many fonctions for every category if i can solve like this. if not; i have to make each fonction for each category. ( + where r u from? )
[eluser]Tominator[/eluser]
I'm from Slovakia. I think I understand You have to set to your routers.php (/application/config/) something like this: Code: $route['category/:any'] = $route['category/index/$1']; Then when you cal: http://yoursite/category/keyboard It automaticaly redirect you to: http://yoursite/category/index/keyboard That means, that your controller will be 'Category', method 'index()' and uri segment 3 will be 'keyboard'. Tom.
[eluser]demiRon[/eluser]
ohh god! i can do this with .htaccess modrewrite. i try to find best solution. Thanks for helping.
[eluser]demiRon[/eluser]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /category/index/$1/$2 [L] maybe like this |
Welcome Guest, Not a member yet? Register Sign In |