Managing PHPs - Advanced

Created by Jake Baker, Modified on Mon, 12 Feb at 1:23 PM by Jake Baker

This article will explain some of the more advanced features of editing PHP Template. These features will help you get the most out of your Personal Housing Plans, making them more effective. 


Note: Whilst a basic PHP template can be created with very limited technical knowledge, utilising more advanced features of PHPs will require some degree of technical expertise or the willingness to learn some of the basics of HTML, CSS and the in-built features of HPA2.

Locata cannot offer training on HTML or CSS, but we are happy to point you towards some other resources. We can also configure the template you desire on a consultancy basis. For more information, or to see examples, please email [email protected]


TABLE OF CONTENTS


Placeholder Tags- Pre-Populating your PHP with client and case data

The PHP configuration page allows you to configure plans to pre-populate with information from the client record, including circumstances for the current case and details about household members. This feature allows you to prevent officers duplicating information entry - as information they capture within the case will appear in the plan automatically if you have configured your Placeholder Tag correctly. 


To include data from a client record, you need to create a Placeholder Tag in a specific format, an example is below:


{0|SAL}


The above Placeholder Tag comprises of what type of data it is (Entity Type) and the unique identifier of the question (Code). In the above example, SAL is the element code for the Client's name as you would use on a letter - for example "Mr John Smith". Putting this Placeholder Tag on a template, would pre-populate it with "Mr John Smith" in the place we added the Placeholder Tag. 


You can find out what type of element a question is and it's element code in a couple of ways:

  1. Find the element within the workflow configuration pages (see this link)
  2. From within the PHP template page, click the "Here" link in the right hand panel where it says "Click here to get a list of elements" (We will be improving the visibility of this in the near future)


You're looking for the "Entity Type" and "Code" sections of the question, as shown below:



Once you know which element you'd like to add into your template with a Placeholder Tag, the next step is to write the Tag and add into the relevant section. Follow the below steps.

  1. Open the relevant PHP template
  2. Click "View Items" against the section you'd like to add the Placeholder Tag into
  3. Click "Edit" on the item you'd like to add the Placeholder Tag into (or create a new item), then click into the "HTML" field 
  4. Enter the Placeholder Tag in the format of {ElementType|Element Code} e.g. {7|FA_DEBTS_RENTARREARS}



Did you know: This Placeholder Tag will make the information held against that element appear within the item of my choice. It's important to note that if the element within the case workflows has not been answered, i.e. it is blank, then no information will display on the PHP when generated by the officer. 


You'll note in my Placeholder Tag, that instead of writing "Case", instead the Entity Type is displayed as "7". The below explains what number to use for each Entity Type:

0 = Special Field 


Special Fields include:

SAL              -  Client Name
CLIENT_CODE      -  Client Reference Number
CASE_CODE        -  Case Reference Number
DATE             -  Current Date
USER             -  Current User's Name
USER_TELEPHONE   -  Current User's Telephone Number
USER_EMAIL       -  Current User's Email
CASE_STATUS      -  The status of the current case e.g. Open, Closed


6 = Client

7 = Case 

8 = Household Member


Note: Further configuration is required to pre-populate PHPs with Household Member information. This is explained further here within this article. 


Conditional Statements - Defining when to prepopulate your PHP with data

Conditional Statements, when combined with Placeholder Tags, allow you to build PHP templates which are dynamic, adapting to the various ways questions might have been answered as part of the case workflow. Examples of this in practice are shown further into this section. 


The below is a snippet of how a conditional statement is structured:


{if|ElementType|Element Code|Condition|(optional) Value}some text here{endif}


Here's a breakdown of the various parts to the above structure:

If                - This tells the system that this is a conditional statement
ElementType       - See the guidance around creating Placeholder Tags 
ElementCode       - As above
Condition         - What needs to be true for the Conditional Statement to be applied. 
Value             - The value that must be true for the Conditional Statement to be applied.
Some text here    - You could put a Placeholder Tag here, or your own bespoke statement. This is what     appears when the Condition is met. 


Conditions within a Conditional Statement can include:

=         The ElementCode matches the Value within your statement.
!=        The ElementCode does not match the Value within your statement.
>         The ElementCode is more than the Value within your statement. 
>=        The ElementCode is more than or equal to the Value within your statement.
<         The ElementCode is less than the Value within your statement.
<=        The ElementCode is less than or equal to the Value within your statement.
e         The ElementCode has a value i.e. it has been answered.
ne        The ElementCode does not have a value i.e. it has not been answered


Here's an example conditional statement, followed by an explanation of what it does.


{if|7|REASONLOSS|e} Reason for Approaching Us: {7|REASONLOSS}{endif}    


The Condition for the above statement is "e" or "The ElementCode has a value". What this means is that where the condition is met, the text between the opening Conditional Tag (that begins with "if") and the ending Conditional Tag (that ends with "endif") will be displayed. Below is how that displays in practice on our PHP template.



Note: When you're using the "e" or "ne" conditions, you don't need to add a value to your Conditional Statement string - like I haven't above. The below is an example of a string using the "=" operator, followed by how it looks on our template.

{if|7|DOYOUHAVEPETS|=|Yes} Pets in your house: {7|PETSDETAILS}{endif} 

 



To add your own Conditional Statement to a PHP template, follow the below steps:

  1. Open the relevant PHP template
  2. Click "View Items" against the section you'd like to add the Conditional Statement into
  3. Click into the "HTML" field of the item you'd like to add the Conditional statement into (or create a new item)
  4. Enter the Statement in the format of {if|ElementType|Element Code|Condition|(optional) Value}some text here{endif}


 


People Statements - Pre-populating your PHP with Household Member data

Some Elements are stored as "Person" elements. The benefit of these type of elements, is that you can answer them for each household member - as opposed to Case elements which you answer once per case, regardless of the number of household members. Below is an example of a Person Element - Date of Birth.



In order to populate our PHP templates with Household Member information, we need to follow some additional steps, namely adding a People Statement, which is compiled as below:


{people}some text here{endpeople}


The text between the opening and closing tags will repeat for each person in the client's household. Between the two People Tags, you could add Placeholder Tags for client, case or person elements. We've provided an example People Statement below. 


{people}{61|FORENAME} {61|SURNAME}{endpeople}


The above People Statement would display on our plan the Forename and Surname of all Household members. We can combine People Statements with Conditional Statements to further enhance our PHP templates, see the below, where we have actually used multiple Conditional Statements inside of a single People Statement. 


{people}{61|FORENAME} {61|SURNAME} {if|61|SPTNEED_0|=|Yes}No Support Needs |{endif}{if|61|SPTNEED_2|=|Yes}Young Person Aged 16-17{endif}{endpeople}


Below is how the above statement translates onto our PHP template. The statement has run for each Household Member, dynamically reflecting the differing answers given against each Household Member. 




To add your own People Statement to a PHP template, follow the below steps:

  1. Open the relevant PHP template
  2. Click "View Items" against the section you'd like to add the People Statement into
  3. Click into the "HTML" field of the item you'd like to add the People Statement into (or create a new item)
  4. Enter the People Statement in the format of {people}some text here{endpeople}


 

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article