Hello,
Nice. I'm talking with my book author. I'm used to read philosophy books, and believe me, I've never had the pleasure. Plato's is long away gone. :)
(you may read after the bold only). :)
Quote:
|
Well, I dunno if what you propose is actually doable, where you pass in an ID straight to the controller without even calling a function.
|
Yes. The all point was to avoid the duplication on the URI like /category/cat/ and product/prod/ or something like this.
I was trying to do that inside the index method of the controller, but, for actually make that work, I needed to explicitly write the /index/ on the URI, (since CI only passes segments values as variables after the second segment. (I believe we can change this, but I don't feel like)) - but, having /category/cat/ or /category/index/ it stills not to be a clean method for this site URIs.
But maybe it will be there where the Routing you have mentioned above, may help hm? I don't know because, here:
http://codeigniter.com/user_guide/general/routing.html
it seems that all the examples tend to work out solution for when a user types directly the url on the browser. But Maybe I'm wrong.
Anyway, I'm missing the point already:
I'm now having a method other then index on my controller to handle it.
Question:
on the first code snipped on page 91:
You have:
$data['category']=$cat;
I believe this is a key step on all this, but I don't quite get what does it do... let's see:
We are storing a specific category id coming from the 3th segment on our URI, to a variable name $cat, and, we have storing that $cat on an array key named category.
That array key among other keys, will then be loaded to be accessible on all views, and then, we load a template view to grab and work with that $data.
I now expect to see some $category somewhere... on the view file, since CI transforms keys to $vars (I don't recall the php function that does that) and, on page 96, here it is, or $category var.
If all this assumptions are correct:
I'm not quite getting, how can we just do something like $category->name for example, and grab the name.
If the $category as an ID on it, let's suppose, 3, it seems that we are telling: 3->name, and doesn't make sense...
Regards,
Márcio