Example: Change search template & change edit template

1. Open the portlet Directory. On the tab Advanced, check the box Search template.
Screenshot of the tab Advanced
2. Click the button Edit template.
Screenshot of the window Edit template
The template is already enabled for searching on three attribute in the directory: search_givenName, search_sn or search_ou (department).

3. If you would like to search for username instead of department, you will need to change the following lines

<div style="float:left;$labelWidth"><label class="$!labelClass" for="#namespace('ou')">$action.getText('ou'):</label></div>
<div style="float:left;$inputMargin"><input class="$!inputClass" id="#namespace('ou')" name="search_ou" size="$inputSize" /></div>

through swapping Department (ou) for Username (cn) and search_ou for search_cn:

<div style="float:left;$labelWidth"><label class="$!labelClass" for="#namespace('cn')">$action.getText('Användarnamn'):</label></div>
<div style="float:left;$inputMargin"><input class="$!inputClass" id="#namespace('cn')" name="search_cn" size="$inputSize" /></div>

OBSERVE! All attributes need to begin with search_ in the search template.
OBSERVE! Only preset attribute can fetch the label (heading) with the method $action.getText(''). If swapping an attribute for another you need to add the label.
You can also search for username:
Screenshot of search in the directory on username

Change the Edit template

1. Open the portlet Directory. On the tab Advanced, check the box Search template.

2. Click the button Edit template.

Screenshot of the window Edit template
The template is preprepared and enabled for changing six attributes in the directory:
- edit_givenName (förnamn)
- edit_sn (efternamn)
- edit_ou (enhet)
- edit_telephonenumber (telefon)
- edit_mail (e-postadress)
- edit_title (titel)
OBSERVE! In order for this to function the user needs to have rights to the directory. Othwerwise the user will not see a change link.

If using the internal directory service (Apache DS) you need to remove the access control check in the detail template in order to see the Edit link. On row 19 you remove the row:
#if ($action.getEffectiveRights($user))
and the following #end on row 24.

3. If it only should be possible to edit surname and email you need to remove the lines containing givenName, ou, telephoneNumber and title.

   <div style="float:left;$labelWidth"><label class="$!labelClass" for="#namespace('givenName')">$action.getText('givenName'):</label></div>
   <div style="float:left;$inputMargin"><input class="$!inputClass" id="#namespace('givenName')" name="edit_givenName" value="$!action.getAttribute($user, 'givenName')" size="$inputSize" /></div>
   <div style="clear:left"><p style="display:none"> </p></div>

   <div style="float:left;$labelWidth"><label class="$!labelClass" for="#namespace('ou')">$action.getText('ou'):</label></div>
   <div style="float:left;$inputMargin"><input class="$!inputClass" id="#namespace('ou')" name="edit_ou" value="$!action.getAttribute($user, 'ou')" size="$inputSize" /></div>
   <div style="clear:left"><p style="display:none"> </p></div>

   <div style="float:left;$labelWidth"><label class="$!labelClass" for="#namespace('telephoneNumber')">$action.getText('telephoneNumber'):</label></div>
   <div style="float:left;$inputMargin"><input class="$!inputClass" id="#namespace('telephoneNumber')" name="edit_telephoneNumber" value="$!action.getAttribute($user, 'telephoneNumber')" size="$inputSize" /></div>
   <div style="clear:left"><p style="display:none"> </p></div>

   <div style="float:left;$labelWidth"><label class="$!labelClass" for="#namespace('title')">$action.getText('title'):</label></div>
   <div style="float:left;$inputMargin"><input class="$!inputClass" id="#namespace('title')" name="edit_title" value="$!action.getAttribute($user, 'title')" size="$inputSize" /></div>
   <div style="clear:left"><p style="display:none"> </p></div>

OBSERVE! If you would like to add an attribute not located in the template, do not forget that all editable attributes should begin with edit_
4. When you have done a search and received the list result, you can click on a name and read the details about the person in the directory. There is also a change-link. If clicking it you will be able to change the surname and the email.

Denna sida publicerades: 2015-05-13

Skriv ut PDF-avsnitt

Hjälpte informationen på den här sidan dig?

Find us!

SiteVision AB (Headquarter)
Vasagatan 10
702 10 Orebro
Sweden

Info: +46 19-17 30 30
Support: +46 19-17 30 39

Latest Tweets