In the current version of application, on posts view page non-logged in users have no actions to choose. It is very inconvinient since non-logged in users can preview posts list and all posts. On the post index page, there is no need to add any action buttons, but on the post view page it would be easier to move between posts pages if ‘Lists Posts’ button appears.
The following line displays ‘Lists Posts’ button that takes from Post view to posts list (index.ctp). It would be displayed for not only non-logged in users, but also for logged in users and for admin.
Non-logged in user can move to the list posts index from post view:
Substr function is a php string function that returns part of a string.
To posts index page looks more clearly substr function was used to display only first 15 characters from the post’s content. At the end ‘…’ was added to mark used function.
Posts index with shorten post content:
To create FormEnum the first file that has to be modified is the UsesController.php :
After that user add.ctp file was altered:
Unfortunately refreshing the user add page returns error:
In order to fix this error FormEnumHelper.php helper has to be added to app/View/Helper.
Once this file has been added to the appropriate folder on the server admin can see drop-down menu for user roles:
To display drop-down disabled list for non-admin users, the following else statement was added to the already existing if statement (in add.ctp and edit.ctp files):
Right now new users can see disabled role during registration process:
And an existing non-admin users can also see disabled role on edit user profile page: