I have two similar user profiles, and they share pretty much the same view structure and information. However, a "special user profile" would display an additional block, and require a different URL - say, /user/igor and /special-user/igor.
What's the best approach to handle this?
In other frameworks I would have pseudocode similar to this:
class UserController extends Controller {
/** @url /user/{$slug} */
function actionSimpleUser($slug) {
if (!$this->viewHas('special')) {
$this->toView('special', false);
}
return $this->render('user', ['slug' => $slug]);
}
/** @url /special-user/{$slug} */
function actionSpecialUser($slug) {
$this->toView('special', true);
return $this->forwardAction('user/simpleUser', [$slug]);
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire