Dynamic page |
[eluser]jdfwarrior[/eluser]
Use _remap. Here's something to get you started. Code: <?php You wouldn't have to use the include function. When you load a view and pass the data to it, that data is accessible within the view. Seems like your not really experienced with loading views and such with CI. Go back and check out the user guide articles on Views and Controllers
[eluser]Helmasaur[/eluser]
It's like this I wanted to do like this. But I would like to know of to do if for examle I want to display for example the texte : Code: <p>Population</p> I should do like this ? Code: $data['title1'] = ''; Or I can use the language function ?
[eluser]jdfwarrior[/eluser]
This is an example of loading the data in the controller: Code: <?php This would be an example of the view file named template.php that is loaded from the controller, and displaying the data that was set in the controller. Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> You load data into an array variable in the controller and then pass that variable to the view. Each item is then accessible within the view file.
[eluser]Helmasaur[/eluser]
OK thank you very much. I can create my site now ! EDIT : Uh. Yes it works well. But if I want to use the same view with different structure in the body. How do I should do ? (Escuse-me)
[eluser]jdfwarrior[/eluser]
Do the same thing for different functions. Just change the data that is loaded in the controller and pass that data to the view.
[eluser]jdfwarrior[/eluser]
You really should go back and read through the documentation more though. I can tell you how to do little things all day long, but if you havent read through the documentation and understand what your doing, then you'll never be able to do this stuff alone. CI has great documentation. It's really easy to learn.
[eluser]Helmasaur[/eluser]
Yes I know it. It's very good but I would like to know if there is a function to have a view with all exept the content. And include the content wich is riten in the URL : example.com/index.php/page/sub_page In the global view is loaded the content and the data comes from for example the database with the filter : sub_page. All is moreless done but I would like to know if with CI, it's possible to do like this or I should use all the time the inclusion of head, header and footer.
[eluser]jdfwarrior[/eluser]
That is where you get into using the _remap function like I showed you earlier. The way CI is set up, it load/calls things in this manner. http://www.example.com/controller-name/f.../arg2/etc/ So if you entered example.com/country/France in the url, it would load the Country controller, and call the France function. In your situation, you do not want to have to create a function for all the possibilities. You would use the _remap function, which overrides calling functions by the name specified in the url. You catch the name in the url with the _remap function and from there, determine how to handle the data. So, in the example I gave you earlier. Code: function _remap($func) {
[eluser]Helmasaur[/eluser]
OK, thank you. I'll do like this. I was not sure I'll be aible to do what I wanted. But if you say it's this. I'll try.
[eluser]jdfwarrior[/eluser]
This will work if I understand what you are wanting to do correctly. I have used this method before. A project I worked on previously, I wanted the Administrative users of the site to be able to create new pages on the site, similar to a content management system. So I laid down nothing but a frame for the site. All pages were database entries. Urls were in the structure of example.com/pages/pagename. The remap function would check the database for a page that was identified by pagename. If it existed, the data was retrieved, and loaded into a view. Otherwise, it would display a 404 error. You can also take it one step further for scenarios such as mine. I used Routes to remove 'pages' from the url. So a page that was previously access via http://www.example.com/pages/directory, would now be access via http://www.example.com/directory because of the Routes I had created. |
Welcome Guest, Not a member yet? Register Sign In |