Well,
Sorry for these long posts. It's often hard to explain what's going on and might be annoying to read.
I've been dabbling a bit in Joomla to create some simple/custom components.
While my final solutions works I still have many questions.
I had to follow the Joomla MVC way of doing things to make this happen.
While using the Joomla framework I've never really grasped the "whole" or "basics" of MVC itself.
It was always "tainted" with a lot of Joomla stuff.
You really need to learn how Joomla implements MVC in order to truely understand the whole and I'm not there yet (by far).
Since this was never 100% clear and because even the "simple" Joomla "hello world" tutorial :
http://docs.joomla.org/Developing_a_Model-View-Controller_(MVC)_Component_for_Joomla!2.5
Is not really that simple to completely grasp I thought of just trying to build my own very very simple MVC app, just to figure the basics out some more and make the basic working principles of MVC a bit clearer.
Of course my little experiment will be a lot more basic and less "clean" or correct.
It was just my way of learning and understanding it more using a real world , yet simplified , example.
I suppose I often need to DO something completely myself to really "grasp" the basics.
I agree that at this time using an established framework would be a lot better suited for production applications etc.
But getting into one or deciding a good one to use and really understanding the basics keeps my head spinning. Again that's why I just tested this stuff "on my own" first.
Often a lot of the clean and beautiful implementations (like in Joomla) make it not always as easy to learn.
It seems as thought the complete basics are hidden in all these nice and clean layers, wrappers for everything.
Give me a crude ,unsecure , ugly and basic example , that seems to work for me best
***
A few more questions...
Is it always advisable to use a clean URI ?
(ripped the next example from wikipedia)
At this time I'm using something like :
http://example.com/products?category=2&pid=25
instead of
http://example.com/products/2/25
Is there a huge advantage in using the clean URI and should one make a priority of implementing something like this ?
***
Thanks for confirming that it's normal to pass everything to index.php. I also came to this conclusion, just wanted to verify if that it's ok.
It seemed a bit strange that every time I pass parameters to index.php the controller object will be created again.
Will it truely be recreated or will it in fact be reused if it somehow already exists because of previous operations ?
***
The start() method of my controller will always run after going to index.php.
In the start() method it will be determined what will be the right functions to call depending on the parameters that are being transferred to the index.php. Maybe I mixed the "router" and "controller" a little bit here.
It seems like my controller :
1. "routes" the code to it's right part
2. Runs the right code (make calls to the model , transfers returning data to the correct view)
***
My queries indeed exists only in the model.
But somehow for every seperate view that wants to use a query result I am calling this query result again via the controller using the models function.
I'm not sure if it's possible to use one query result throughout more than 1 view .
So my query itself is indeed reused in more than one view (it exists only in the model) and so a few different views rely on the same model function to get the data. But the query result data itself is never shared and needs to be "demanded" again for each view even though it is in fact the exact same result data.
My controller does this kind of transferring :
1. controller demands the model to run the function that returns the correct data
2. controller transfers this data to the view.
If my 3 default views are shown , using the same data , they all have their own instance of resulting query data.
Is that the/a right way of doing it ?
*-*-*-*-*-*-*-*
I think I'll look into some of the (simple) frameworks to see some more implementations of MVC.
But I just wanted to get some feedback on my own stuff to see how far my way of doing things is correct and where it needs some adjustments
I can always post some code examples if that can make things easier to understand.
Thanks again for your reply. It's really really appreciated a lot!