n00bz question |
[eluser]solidhex[/eluser]
Hey all New to CodeIgniter. I have what I think is a pretty simple question (and presumably has a pretty simple answer). Let's say I have a page that displays comments. Underneath the comments I have a link that says, 'Add a comment.' When that link is clicked, I want to show the comment form (duh!). If I were writing PHP from scratch, I could add a query string to the link like so: Code: <a href="foo.php?add_comment=yes">add a comment!</a> I could then read that value using $_GET or $_REQUEST. How can I set that link to be CI friendly so I can use the uri class?
[eluser]nmormino[/eluser]
CodeIgniter doesn't use $_GET what you have instead is a controller that handles a certain type of page. for example : http://yourdomain.com/controller/method/variable in your controller you will have a method function method(variable) { } hope this helps, if not, then I would recommend doing the build a blog in 15 minutes tutorial http://codeigniter.com/tutorials/watch/blog/
[eluser]NateL[/eluser]
Yep, that video tutorial is great for getting your head around the idea of how the URI's work. You don't really have to deal with ?function=dothis
[eluser]solidhex[/eluser]
Yep I watched over the tutorial. I think my question is more about the view file. My view file contains both the form and the comments, but I only want to display the comment form when the user clicks the 'Add a comment' link. I realize this could easily be done with JavaScript, but I am simply experimenting with CI to get my head around how it works.
[eluser]indocoder[/eluser]
if you using the global "view" file , use the IF ELSE statement inside the view for each method but I really not recommend this as a good solution for a beginner.
[eluser]NateL[/eluser]
OH! Sorry.. For that, I don't think you would need PHP at all. just jQuery. Perfect tutorial for you: http://blog.themeforest.net/screencasts/...ers-day-6/
[eluser]solidhex[/eluser]
Ah yes, but as I mentioned I was trying to set it up without javascript - that I know I could do easily I just wanted to test out how to do stuff with CI.
[eluser]solidhex[/eluser]
Here is what the full page would look like, we'll call it index.php: Code: <ol> I suppose I could create two separate views, but that seems wasteful. I think I need to pass in variable via the controller, yes? |
Welcome Guest, Not a member yet? Register Sign In |