I have a couple of pages where I allow users to soft delete and restore records (the SoftDeleteTrait works very well here).
I also allow users to [show | hide] deleted records. There are two separate actions that drive which to show, /index and /all. At first I also had two separate templates, index.ctp and all.ctp.
In an effort to consolidate, I got rid of all.ctp and added some if/else clauses to index.ctp to toggle whether to display the “Show Deleted” and “Hide Deleted” links. I also modified the /all action in the controller to render index.ctp.
This is where my question comes in: is what I did bad practice? I feel clauses like
<?php if ($this->request->getParam('action') == 'all'): ?>
in a template file is dirty. What’s the consensus on this?
Raul, I already have the finder logic defined properly in my controller.
The question centers on the presentation of a link that either displays “Show Deleted” or “Hide Deleted.” I have logic in my template that looks like this: