Creating a New Page Tutorial
This topic will walk you through the steps to use the #ew_create_record
macro to create a record submission form for the Tasks table.
The basic steps for adding a new page to the EUI are:
- Create the HTML template
- Add a link from the menu and/or home page
- Set user permissions and create an end user layout.
To create a page in the EUI that gives end users the ability to submit a task:
- Navigate to the EUI Templates table.
- Copy the template new_user.html to use as a starting point. When prompted, enter the name "new_task.html" for this template record.
- Click Finish.
- Open new_task.html for edit and change the Description to "Page for creating new tasks in the EUI".
The <iframe> tag which contains the #ew_create_record macro will be similar to the following:
<iframe src='#ew_create_record("contacts.employees" "/eui2template/main.php" "parent")' name="content_frame" id="frameres" width="100%" frameborder="0"></iframe>
Replace contacts.employees (the first parameter) with "task" (the logical table name of the Tasks table).
- Click Save.
Working with menu.htm
The next step in making this page accessible is to add a link from the menu by making a few changes to menu.htm. Each menu tab is a list item <li> containing a link to a template page. Menu.htm makes heavy use of conditionals and the method $ewUser.isInGroup to ensure that different types of end users see only the tabs relevant to them.
In the initial default setup, the EUI is configured for users in several different groups. The table below outlines the available functions and navigational tabs each user group sees when accessing the EUI:
Group | Default EUI Tabs |
---|---|
Guest |
|
Internal Customer |
|
Document Creator |
|
Contract Creator |
|
Repair Customer |
|
Any groups not listed above will see the following tabs:
- Home
- New (Support Case)
- View (Support Cases)
- FAQ (Support Cases)
- My Profile
Let's look at the first <li> item in menu.htm:
<li id="main"><a href='#ew_forward("main.php")'>$ewText.get("menu.home")</a></li>
There are a few things to note about the code.
The link's href attribute is formed with the
#ew_forward
macro. This macro forwards the user to the page specified by the $templateName parameter.Using
$ew_forward
keeps the user logged in to Agiloft while navigating between pages.The link text is referenced by the method
$ewText.get()
. We will return to$ewText.get
in more detail a little later.- Each list item is assigned an ID. For the Home tab link above, the ID is "main". Each menu tab is assigned an ID that refers to some part of the URL (i.e. main.php). Note that the ID here only uses the URL name for the sake of convenience.
Highlighting the Active Menu Tab
The menu tab's ID is used in part by the JavaScript function menuChange()
. This simple script allows the browser to recognize the current page and highlight the corresponding menu tab:
In menu.htm, scroll to the Body field. Locate the <script> section and the block of text beginning function menuChange()
.
function menuChange() { if (document.getElementById && document.createTextNode) { if (homepage || location.href.match('main.php')) { document.getElementById('main').className='active'; } else if (location.href.match('new_user')) { document.getElementById('new_user').className='active'; } else if (location.href.match('new_')) { document.getElementById('new').className='active'; } else if (location.href.match('-faq')) { document.getElementById('faq').className='active'; } else if (location.href.match('my_profile')) { document.getElementById('my_profile').className='active'; }else if (location.href.match('my_') || location.href.match('open') || location.href.match('all_')) { document.getElementById('view').className='active'; } else if (location.href.match('chat')) { document.getElementById('chat').className='active'; } } }
This piece of JavaScript looks at the browser's current URL.
- If it finds the 'main.php' in the URL, it assigns the 'active' CSS class to the element on the page with an ID of 'main'.
- If 'main.php' is not in the URL, it goes through the remaining conditions in the script. Next, it looks for the URL string 'new_user' to find a match, followed by 'new_' and so on.
The stylesheet style.css holds a rule that sets the background color of an 'active' menu tab.
Link to the New Page
Example
Let's create a link to new_task.html:
- From the EUI Templates table, open menu.htm for edit.
Copy the helpdesk cases link lines into a new set of lines directly below the originals:
#if ($ewText.get("show.service.requests")=="yes" && $ewPermission.table("helpdesk_case","create")) <li><a href='#ew_forward("new_servicerequest.html")'>$ewText.get("menu.new.sr")</a></li> #end
- Change
$ewText.get("show.service.requests")
to$ewText.get("show.tasks")
. - Change
$ewPermission.table("helpdesk_case", "create")
to("task", "create")
. - In the
#ew_forward
macro, changenew_servicerequest.html
tonew_task.html
. - Change the link text
$ewText.get("menu.new.sr")
to Task. The revised lines of HTML are:
#if($ewText.get("show.tasks")=="yes" && $ewPermission.table("task","create")) <li><a href='#ew_forward("new_task.html")'>Task</a></li> #end
- Click Save.
Set Table Permissions
The next step in creating a task submission page is to create an end user layout and give the appropriate users access permissions to the Tasks table.
- Navigate to Setup gear > Tables > Tasks > Edit > Layout.
- Check if an end user layout exists; if not, copy the Power User layout and make additional changes if desired.
- Click Finish to save the changes.
- Navigate to Setup gear > Access > Manage Groups, then edit the Customer group.
- On the Table tab, find and edit the Task table.
- On the Record Permissions tab, allow the group to Create Tasks and View their own Tasks.
- On the Field Permissions tab, make sure that the Customer group can View own and Create the necessary fields. .
- When you are done, click Finish in the Table Permissions wizard and then Finish again in the Manage Groups wizard.
- View the completed task submission page in the EUI.