Welcome Guest, Not a member yet? Register   Sign In
Beginner Help - How to get domain.com/Dashboard/Campaign/ID/Contact/ID URI
#1

[eluser]joshlindsay[/eluser]
I'm building a system to manage my marketing campaigns and need to help on structure to achieve the following URI structure.

Dashboard - List Campaigns
Dashboard/Campaign - Add New Campaign
Dashboard/Campaign/123 - View Campaign with ID 123
Dashboard/Campaign/123/Contact - View all Contacts for Campaign with 123
Dashboard/Campaign/123/Contact/34422 - View Contact with ID 34422

I've tried googling but not entirely sure what I'm searching for.
It becomes confusing when a

Do I have a single controller called Dashboard or can I have a Dashboard, Campaign and Contact controller?

Any tips as to how you would structure this project would be much appreciated to get me on the right track..

Thank you.
#2

[eluser]InsiteFX[/eluser]
Dashboard controller.
Campaign controller and model, database table campaigns.
Contact controller and model, database table contacts.

#3

[eluser]joshlindsay[/eluser]
[quote author="InsiteFX" date="1377275703"]Dashboard controller.
Campaign controller and model, database table campaigns.
Contact controller and model, database table contacts.

[/quote]

Excellent. That's what I've got so I'm on the right track.

How do I get access to the Campaign and Contact controllers and functions from the Dashboard?
Do I need to run a check to see if segment 4 (contact) is NULL - if so load Campaign if not load Contact?

Is there a specific topic I should be researching to find my answers?

Thanks
#4

[eluser]InsiteFX[/eluser]
There are multiple ways of doing.

Routes:
CodeIgniter URI Routing

URI Class using segments:
CodeIgniter URI Class

#5

[eluser]joshlindsay[/eluser]
Thank you. I had been reading about routes over the last week but couldn't figure out if it was what I needed. After seeing that was the correct way to go I've added the following to my routes config

Code:
$route['(:any)/contact'] = "contacts/addContact";
$route['(:any)/contact/(:any)'] = "contacts/viewContact";
$route['(:any)/campaign/(:any)'] = "campaign/viewCampaign";
$route['(:any)/campaign'] = "campaign/addCampaign";

This achieves the following
dashboard/campaign - adds new campaign
dashboard/campaign/22 - views campaign 22
dashboard/campaign/22/contact - adds new contact to campaign 22
dashboard/campaign/22/contact/44 - views contact 44 from campaign 22

It does appear to be working however is this the best way to achieve my structure?

Thanks InsiteFX for your assistance




Theme © iAndrew 2016 - Forum software by © MyBB