Welcome Guest, Not a member yet? Register   Sign In
Can you suggest a better URI vs CRUD system for a forum?
#4

[eluser]PhilTem[/eluser]
[quote author="nullsys" date="1340286836"]
I like the $param system, but I'm still going to have to use the following:

Code:
if ($param1 === "category") {
//Create category
}

Inside each of the create/edit/delete methods right?
otherwise, how else would the controller know which one I want to edit, etc.[/quote]

You're right. However, I think you might also use

Code:
$route['(create|edit|delete)/(category|topic|post)/(:any)'] = 'CRUD/$2_$1/$3';
$route['(create|edit|delete)/(category|topic|post)'] = 'CRUD/$2_$1';

Watch the added underscore between $2 and $1 as well ass the switched parameters $1 and $2.

That way (I'm not 100% sure this will work since my RegExp knowledge is very low) you can have methods like

Code:
function category_edit($param_3) {}
function category_create($param_3) {}
function category_delete($param_3) {}

And so on a so forth for topic and post the same.
This would save you time writing the

Code:
if ($param1 === "category") {
//Create category
}

parts


Messages In This Thread
Can you suggest a better URI vs CRUD system for a forum? - by El Forum - 06-21-2012, 08:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB