Login to the admin system using the default root account (unless you created another account already - you will need ROOT access though).
Navigate to Control Panel (notice that Website Admin does NOT appear) and Site Editor. Go to Controllers. Once the Controllers applet opens, check that there is an entry for guestbookAdmin in the list of available controllers for the default plugin. If it is NOT there, manually add it using the "Add" button.
Next, using the menu on the right of the screen (below Control Panel), select Controller Map. Once this applet loads, edit site 2. You will see a list of all the available controllers by plugin for the site. Our new controllers should be listed without checks in the boxes. Add BOTH the websiteAdmin controller AND the guestbookAdmin controller and save the changes.
Now click "rebuild". This will require that the controllerMap.xml file is readable and writable by the webserver process - if not this step will error. On the warning, click OK to continue. You should then see a green success message.
Return to the control panel and a new section should appear listing guestbookAdmin. Go to it and you should see a typical DAO admin interface. Create an entry to test that all is working as it should. The interface of the form will likely not be very practical though, and perhaps you do not really want to be able to add items to the guestbook.
Back to your editor, find and open both the guestbookAdmin list and form templates. You will see that the object properties have been extracted and made available by default in these templates. Lets customise the list first by trimming down the number of columns.
Simply delete the entire line from within the foreach loop to stop it being displayed - remember to update the table headings!
Switch back to the web browser to see the changes.
Next the form, we should not see the primary key or edit it, so we need to update the form to hide it and to make some other changes such as making the comment a textarea. Customise as you see fit, but take note of the field names - any field that you remove should be added to the hidden section as input type="hidden".
When done, save the changes and check them out in the web browser.
The final step of the admin process is to remove the "add" new entry functionality. For this we need to go back to the controller class file. Find the following section of code:
/**
* @see mvcControllerBase::__construct()
*/
function __construct() {
parent::__construct();
$this->setSelectedMenuItem('controlPanel');
$this->setControllerView('guestbookAdminView');
}
and add the following after it:
/**
* @see mvcControllerBase::__construct()
*/
function __construct() {
parent::__construct();
$this->setSelectedMenuItem('controlPanel');
$this->setControllerView('guestbookAdminView');
}
/**
* @see mvcControllerBase::initialise()
*/
function initialise() {
parent::initialise();
$oItem = new mvcControllerMenuItem(self::ACTION_NEW, 'New', self::ACTION_NEW, 'Create a new record');
$this->getMenuItems()->getItem(self::ACTION_VIEW)->removeItem($oItem);
}
Now save and reload the web browser - the ability to add an item has been removed.
Posted by: Dave Redfern (Writer), in Tutorials on 12 Apr 2008 @ 13:51
Tags: dao, generator, guestbook, mvcgenerator, scorpio, tutorial,
Contents:
Related Articles
This
work is licenced under a
Creative Commons Licence.