Dynamic Content in CI |
[eluser]seismic[/eluser]
Can somebody give me a link to guide how to put dynamic content in the content-div (in view file) I mean how to put the "variable content" (article01, article02, ... ) properly? How is it done in CI way? I've check out the guide here and i couldn't find any directives to implement this common thing. Should I handle the content files in the view folder and load them by passing $variable (taken from the link ?page=article01) through (my default) controller into the index.php (main html file) in the view? So then choosing it normally by switch/if and php include? What about the Model part? How do you make it?
[eluser]seismic[/eluser]
Blah... this gives nothing, even some directions! You're really unhelpful giving such reference.
[eluser]theprodigy[/eluser]
Not exactly sure what you are asking. There is a section in http://ellislab.com/codeigniter/user-gui...views.html called "Adding Dynamic Data to the View" Will that help?
[eluser]stuffradio[/eluser]
Pff, this is basic and in the User guide ![]() Code: //mycontroller.php Code: //myview.php
[eluser]seismic[/eluser]
I already read carefuly the user guide ![]() There is no mention how to input the "variable text" or the "variable file" in the div of template. Stuffradio what about if "some value" will be a big article (one of many) taken from the file(html essence with h1,h2,p etc symbols) and it depends from the parameter taken from the link? (i know how to get the variable from the link already). For example i have 2 articles here. Default Controller: Code: <?php view/view_index.php Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" Should I store article/files in the view folder (in eg. view/articles/article01)? What extension should i use? What extension do you prefer? What about Model doing here? Should i use the Model class somewhere here?
[eluser]stuffradio[/eluser]
KISS (Keep it simple stupid) Models -> Handles all database transactions Views -> All the stuff that gets outputted to your brwoser Controllers -> Controls what happens, logic can happen in here too. You can store content for certain pages in a database. Say you have page A, in your browser path you can go http://mysite.com/index.php/page/index/A You take the value from the 3 segment, that's the value A. You go to the model and fetch the data for page A. You store the values of page A in variables and load them onto the view. Try playing around with that concept, I have to go to school now... I'm sure others can help if you have other questions while I am gone.
[eluser]seismic[/eluser]
stuffradio THNX! This is how i make it: Controller: Code: <?php Model: Code: <?php View: Code: <HTML><head></head> Maybe someone has idea to make better solution?
[eluser]Phil Sturgeon[/eluser]
Ok fine, I'll throw in. Now you have your articles/pages/whatever loading dynamically using URI parameters, you now need to link to these dynamically. The best way to do this, is to retrieve a list from the database, which should hold id and title already. model: Code: // add me view: Code: <HTML><head></head> All of these basic concepts are shown here and in a thousand other places on the internet.
[eluser]stuffradio[/eluser]
Some things I notice in your model is this Code: $this->load->database(); You don't need that because in your autoload I assume you have database in the autoload file. This is what I have Code: $autoload['libraries'] = array('database', 'session', 'security'); Security is a custom library I made. Also, in your controller... aren't you mixing PHP 4 with 5? And another thing, you don't put parent::Controller() in your index function, that does the same thing as the __construct function in the Test function. |
Welcome Guest, Not a member yet? Register Sign In |