Welcome Guest, Not a member yet? Register   Sign In
newbie...question, application flowcontrol
#1

[eluser]julgus[/eluser]
Hi
I have just downloaded CodeIgniter, read the documentation and will start to migrate a existing application into this framework for a test.

My question is about flow control, consider the following:

I have a menu which, when addresed, shows a table of records.
When I select a record a new display is show showing details about this record
When selecting, let say messages, from this screen, a new screen is shown with data.
And finally, when I select a message from the overview this message is shown.

Will the final url's look like something:

http://test.se/index.php/overview
http://test.se/index.php/overview/2
http://test.se/index.php/overview/2/messages
http://test.se/index.php/overview/2/messages/3

How do I write this in Codeigniter. Is this one class? Can I have several views connected to one class?

Thanks in advance for helping a newbie..!

Regards
Johan
#2

[eluser]BaRzO[/eluser]
Take a look at this topic you'll see very useful links at the and there is video links i am sure you'll watch them many times cuz i did Wink
#3

[eluser]lmv4321[/eluser]
[quote author="julgus" date="1226253265"]Hi
I have just downloaded CodeIgniter, read the documentation and will start to migrate a existing application into this framework for a test.

My question is about flow control, consider the following:

I have a menu which, when addresed, shows a table of records.
When I select a record a new display is show showing details about this record
When selecting, let say messages, from this screen, a new screen is shown with data.
And finally, when I select a message from the overview this message is shown.

Will the final url's look like something:

http://test.se/index.php/overview
http://test.se/index.php/overview/2
http://test.se/index.php/overview/2/messages
http://test.se/index.php/overview/2/messages/3

How do I write this in Codeigniter. Is this one class? Can I have several views connected to one class?

Thanks in advance for helping a newbie..!

Regards
Johan[/quote]

Based on your description, I might do something where the urls would look more like this:
http://test.se/index.php/overview
http://test.se/index.php/overview/record/2
http://test.se/index.php/overview/record/2/messages
http://test.se/index.php/overview/record/2/messages/3

overview would be a controller (overview.php) in the controller folder. The default function of index would call a view to show a table of records. Each of these records would have a link like http://test.se/index.php/overview/record/{$id}. When the user clicks on this link, they are directed to the function record in the overview controller and the id of the record is passed in as the first parameter. Since no other parameters were received, the user would by presented with a view that contains the details of the record. When they click on messages (http://test.se/index.php/overview/record/{$id}/messages), they are directed to the function record in the overview controller and the id of the record is passed in as the first parameter with 'messages' as the second. The user is then presented with a view to display all of the messages for that record. When they click on a single message (http://test.se/index.php/overview/record/{$id}/messages/{$mid}), they are directed to the function record in the overview controller and the id of the record is passed in as the first parameter with 'messages' as the second and the message id as the third. The user is then presented with a view to display the details of the message.

So, 1 controller with 2 public functions and 4 views being called.

This may not be the only way to write it. This is just off the top of my head.
#4

[eluser]julgus[/eluser]
Hi

thanks, I've now got the hang of it... seems sweet this and will save me from endless logical application flowcontrol.




Theme © iAndrew 2016 - Forum software by © MyBB