Sidebar

Using iTop

Creating your iTop

iTop Customization

"How to" examples
DataModel

User Interface

Automation & Ticket management

Portal Customization

You are browsing the documentation for iTop 3.1 which is not the current version.

Consider browsing to iTop 3.2 documentation

Portal: How to add a create button

In this How to, we use the CreateBrick to add a quick request button.

name:
How to add a create button
type:
How To
audience:
Administrator, Integrator, Developer
level:
Intermediate
duration:
30min
keyword:
Portal, Customization
iTop version:
2.3.0

Prerequisites

What you will need to:

  • Know how to make an iTop extension and upgrade your system,
  • Have an iTop system with the demo data and the enhanced portal installed,
  • Have access to an account with enough rights to connect to the portal (usually this means having the Portal User profile).

Aim of this tutorial

In this tutorial, you will learn how to:

  • Add a brick to the default portal
  • Use the CreateBrick brick to make a button opening a creation form anywhere in the portal

 Create button

Step by step instructions

Creating the extension

First, we need to create an iTop extension that will alter the portal XML configuration to add a new brick. Check the Extension modules part from the customization guide (iTop Customization) if necessary.

  1. Name the extension as sample-portal-add-button.
  2. Remove the main.sample-portal-add-button.php file as we won't need any PHP code.

You should have the following structure:  Module structure

Changing the portal configuration

Now that we have the extension, we just need to make an XML delta and change the portal configuration to add the brick. Open the datamodel.sample-portal-add-button.xml file and paste the following code:

datamodel.sample-portal-add-button.xml
<?xml version="1.0" encoding="UTF-8"?>
<itop_design xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
  <module_designs>
    <module_design id="itop-portal" xsi:type="portal">
      <bricks>
        <brick id="quick-new-user-request" xsi:type="Combodo\iTop\Portal\Brick\CreateBrick" _delta="define">
          <active>true</active>
          <rank>
            <default>70</default>
          </rank>
          <width>4</width>
          <modal>true</modal>
          <title>
            <default>Brick:Portal:QuickNewUserRequest:Title</default>
          </title>
          <visible>
            <home>false</home>
          </visible>
          <decoration_class>
            <default>fa fa-bolt fa-2x fa-fw</default>
          </decoration_class>
          <!-- Class that will be create created with the form -->
          <class>UserRequest</class>
          <rules>
            <rule id="contact-to-userrequest"/>
          </rules>
        </brick>
      </bricks>
    </module_design>
  </module_designs>
</itop_design>

This adds a brick to the portal that will :

  • Be placed after the other bricks in both the home page and the navigation menu as its rank is greater than those from other bricks.
  • Not be displayed on the home page.
  • Open the form in a modal dialog instead of redirecting to a whole page.
  • Make a form to create a object of class UserRequest.
  • With some presets from the contact-to-userrequest action rule.

Dictionary entry for the label of the button

Edit the file en.dict.sample-portal-add-button.php to add an entry for the label of the button, as shown below:

en.dict.sample-portal-add-button.php
<?php
Dict::Add('EN US', 'English', 'English', array(
        'Brick:Portal:QuickNewUserRequest:Title' => 'Quick new request',
));

You can repeat the same operation for other languages.

Upgrading the system

Finally run an upgrade of your iTop system with the new extension option checked and access the portal. You should see the new Quick new request button on the navigation menu. Click it and a creation form will open.

 Et voilà !

The main difference with the default UserRequest creation process is that you don't have to go through the services catalog to choose the ServiceSubcategory; allowing you to create objects from anywhere in the portal.

Downloads

You can find this extension with some example themes here: sample-portal-add-button-1.0.0-145.zip

3_1_0/customization/portal_howto_addbutton.txt · Last modified: 2023/07/21 10:19 by 127.0.0.1
Back to top
Contact us