How to change "true/false" to "yes/no" for Form Responses in Ektron - forms

When there are checkboxes on the form, after the form is submitted with email recipients , the emailed response shows "true/false" if the checkbox is "checked/unchecked". Our staffs think it's not very user-friendly as "T/F" seems to be more of a technical term.
How could we change it to "Yes" for checked and "No" for unchecked respectively? "
Version: 8.50 SP2(Build 8.5.0.356)

That's funny; I had the opposite problem with smart forms because those checkboxes are stored in the XML as "yes" and "no". Consequently, I created this extension method for converting a string value into a boolean. "True", "1", and "yes" all convert to a true value.
public static class StringExtensions
{
public static bool ToBoolean(this string str)
{
bool result;
if (str == null)
return false;
if (bool.TryParse(str, out result))
return result;
return str.Trim() == "1" || string.Equals(str, "yes", StringComparison.OrdinalIgnoreCase);
}
}
You'll probably want to look at this file: /workarea/controls/forms/template_buildDataValue.xslt
It is referenced from within this file: /workarea/controls/forms/template_FormFieldValue.xslt
The buildDefaultValue xslt has this loop:
<xsl:for-each select="$data">
<xsl:choose>
<xsl:when test="$field/#datalist">
<xsl:variable name="displayValue" select="$fieldlist/datalist[#name=$field/#datalist]/item[#value=normalize-space(current())]"/>
<xsl:choose>
<xsl:when test="$displayValue">
<xsl:copy-of select="$displayValue/node()"/>
</xsl:when>
<xsl:when test="string-length(normalize-space(.))=0">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="./node()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$field/#basetype='calendar' or $field/#datatype='date'">
<xsl:call-template name="buildDate"/>
</xsl:when>
<xsl:when test="string-length(normalize-space(.))=0">
<xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="$field/#basetype='textbox' or $field/#datatype='textarea'">
<pre style="white-space:pre;word-wrap:break-word;"><xsl:copy-of select="./node()"/></pre>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="./node()"/>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="position() != last()">
<br />
</xsl:if>
</xsl:for-each>
You should be able to add another <xsl:when> element inside the outer <xsl:choose> element and test for the particular $field/#basetype you want.
These files are from the v9.0 workarea, but form emails haven't changed much since v8.5, so hopefully the files are at least very similar for you.
Also, this post may be of help: Customize Ektron HTML Form Email Layout

Related

How can I create a single Datepicker in svelte with carbon-components with german locale

When I try to use the "Datepicker" in svelte with carbon-components I can configure the output to be set in a german locale style but after sending the form, the datepicker only shows "Please match the requested format." I am missing something but I really don`t now what I am missing.
Here is my code
<script lang="ts">
import { DataTable, DatePicker, DatePickerInput, NumberInput, Grid, Row, Column, Button, FluidForm } from "carbon-components-svelte";
let datum: Date;
</script>
<Grid>
<Row>
<Column>
<form>
<DatePicker
format="de-CH"
dateFormat="d.m.Y"
locale="de"
datePickerType="single"
flatpickrProps={
{
locale:
{firstDayOfWeek: 1},
dateFormat: "d.m.Y",
}
}
on:change bind:value={datum}
>
<DatePickerInput labelText="Datum" placeholder="dd.mm.yyyy" />
</DatePicker>
<Button size="small" type="submit">Submit</Button>
</form>
</Column>
</Row>
</Grid>
Screenshot of the error message:
When I remove the formatting stuff, the form works and the date is getting send.
This is a example without formatting with german locale
<script lang="ts">
import { DataTable, DatePicker, DatePickerInput, NumberInput, Grid, Row, Column, Button, FluidForm } from "carbon-components-svelte";
let datum: Date;
</script>
<Grid>
<Row>
<Column>
<form>
<DatePicker
datePickerType="single"
flatpickrProps={
{
locale:
{firstDayOfWeek: 1},
}
}
on:change bind:value={datum}
>
<DatePickerInput labelText="Datum" placeholder="dd.mm.yyyy" />
</DatePicker>
<Button size="small" type="submit">Submit</Button>
</form>
</Column>
</Row>
</Grid>
What am I missing? How can I use german locale with a german date format without getting the Error "Please match the requested format."?
These locale settings consist of various direct props that should be set:
DatePicker: locale & dateFormat
DatePickerInput: pattern
The flatpickr package also provides a large set of locales, I would recommend passing the German one directly to get day and month names.
import { German } from 'flatpickr/dist/l10n/de.js'; // there also is an ESM dir
<DatePicker locale={German} dateFormat="d.m.Y" ...>
<DatePickerInput pattern={'\\d{2}\\.\\d{2}\\.\\d{4}'} .../>
</DatePicker>
REPL
The pattern determines the regular expression used to check the value, so that has to match the input/dateFormat. (Pattern is passed in a string because of the curly braces within, which would cause Svelte to interpolate the number literals otherwise.)

read another node while traversing xml for PDF generation through page2fo.xsl

I am trying OOTB PDF rewriter component and able to generate a PDF for simple use-case however it is not working in some scenarios.
Scenario1:able to generate the PDF when the page has data stored in a single node.
Scenario2: unable to generate the PDF when the paged is referencing multiple nodes.
<xsl:template match="jcr:content">
<xsl:if test="#articleTitle">
<fo:block font-size="30pt"
text-align="start" font-family="DinProLight">
<xsl:value-of select="#articleTitle" />
</fo:block>
</xsl:if>
<xsl:if test="#publishDate">
<fo:block font-size="18pt" color="#777777" text-align="start" font-family="georgia;"
font-style="italic" padding-bottom="9px">
<xsl:value-of select="concat(substring(#publishDate,9,2),'-',substring(#publishDate,7,2),substring(#publishDate,0,5))" />
</fo:block>
</xsl:if>
<xsl:if test="#authorPath">
<fo:block font-size="18pt" color="#777777" padding="3px" text-align="start">
<!--Below Code works fine -->
<fo:external-graphic src="url('sling://etc/designs/XXXX/images/logo.jpg')" content-type="content-type:image/jpeg"/>
<!--Below Code Fails -->
<xsl:value-of select="sling://content/XXXX/en/perspectives/tst_artcl/jcr:content#fullName"/>
</fo:block>
</xsl:if>
<xsl:if test="#noOfViews">
<fo:block font-size="11pt" color="#777777" text-align="right" font-family="arial" padding-bottom="9px" border-bottom="1px solid #777777">
<xsl:value-of select="concat(#noOfViews,' Views')" />
</fo:block>
</xsl:if>
<xsl:apply-templates />
</xsl:template>
the PDF generation by default work by using the default xml rendering of your nodes (content/app/page.xml), but since you need to get information from more than one node I recommend to just create your own xml.
-Register a servlet with PDF extension and your resourceType of choice and render a xml that contains all the information you need and with the most convenient structure. (you can use the resourceResolver inside the servlet to access any node you need).
Then the pdf rewriter will use your xml representation instead of the default one.
for example
#SlingServlet(
description = "Employee PDF",
extensions = { "pdf" },
resourceTypes = { "greatapp/page/employee" },
methods = { "GET" })
public class EmployeePDFServlet extends SlingSafeMethodsServlet {
protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException,
IOException {
//generate an xml here
}
}

Format date compare date XSLT

I have an XML file with description and date about events like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="timedate.xsl"?>
<catalog>
<event>
<name>AAA Festival</name>
<place>New York</place>
<country>USA</country>
<date>19/11/2013</date>
</event>
<event>
<name>BBB Festival</name>
<place>Paris</place>
<country>France</country>
<date>11/10/2013</date>
</event>
<event>
<name>CCC Festival</name>
<place>London</place>
<country>UK</country>
<date>29/09/2013</date>
</event>
</catalog>
and an XSL file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<h2>Upcoming events</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Place</th>
<th>Country</th>
<th>Date</th>
</tr>
<xsl:for-each select="catalog/event">
<xsl:sort select="date" order="descending"/>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="place"/></td>
<td><xsl:value-of select="country"/></td>
<td><xsl:value-of select="date"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I would like to make a page that sort and list only upcoming events (including today date). I'm not able to do this, because dates are not well formatted and I can get current date to compare them and print future events. Please let me know the solution with an example that works. Thanks in advance for your replies and help. Regards!
Idea to compare/sort dates concerned with converting your raw date to number format. For example by formula year*372+12*month*31+day (372 and 31 is ok since you really don't need precise numbers)
If your xml have fixed date format (e.g you sure that 1 is always 01) you can use XPath function substring
EDITED-with respect to your claim I'm placing full sample of xsl.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body>
<h2>Upcoming events</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Name</th>
<th>Place</th>
<th>Country</th>
<th>Date</th>
</tr>
<xsl:for-each select="catalog/event">
<xsl:sort
select="number(substring(date, 7, 4))*372+12*31*number(substring(date, 4, 2))+number(substring(date, 1, 2))"
order="descending" data-type="number"/>
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="place"/></td>
<td><xsl:value-of select="country"/></td>
<td><xsl:value-of select="date"/></td>
<!-- column just for debug-->
<td><xsl:value-of select="number(substring(date, 7, 4))*372+12*31*number(substring(date, 4, 2))+number(substring(date, 1, 2))"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Umbraco XSLT search page navigation using input onchange

I have created a pagination input that on change will go to the value entered into the input.
It will detect the page range and allow navigation between those pages in that range.
e.g /image-gallery-album-1.aspx?page=3
<form type="get" onchange="return false">
<div class="pagerUI">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<!-- previous page -->
<xsl:if test="$page > 1">
<td class="pager-prev"><a class="previous" href="{concat('?page=', $page - 1, $qs)}" title="Previous page">‹</a></td>
</xsl:if>
<td>Page</td>
<td><input type="number" name="page" id="page" min="1" >
<xsl:choose>
<xsl:when test="$page=1">
<xsl:attribute name="value">1</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="value"> <xsl:value-of select="$currentPageNumber" /> </xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:attribute name="max"> <xsl:value-of select="$numberOfPages"/> </xsl:attribute>
</input></td>
<td>of <xsl:value-of select="$numberOfPages"/></td>
<!-- next page -->
<xsl:if test="$page * $resultsPerPage < count($matchedNodes)">
<td class="pager-next"><a class="next" href="{concat('?page=', $page + 1, $qs)}" title="Next page">›</a></td>
</xsl:if>
</tr>
</table>
</div>
</form>
However, when I added this to the XSLTSearch code it doesn't work as the URL loses the search string.
So instead of navigating to: /image-search.aspx?search=football&page=3
It navigates to: /image-search.aspx?page=3 Which doesn't display any results on that page as it's missing the search criteria to display the search results.
I tried to change the form and include an "action" that would change the URL to include the search value but I can't include the input value as it's dynamic.
For example with the below form if I enter any value into the input the URL updates to following: /image-search.aspx?search=otbra&page= It's missing the entered number of the input value.
Search form with onchange and action and method post attributes:
<form type="get" onchange="return false">
<xsl:attribute name="method"> <xsl:text>post</xsl:text> </xsl:attribute>
<xsl:attribute name="action"> <xsl:text>?search=</xsl:text> <xsl:value-of select="$search"/><xsl:text>&</xsl:text>page= (input value)</xsl:attribute>
Is there some javascript or some way of detecting the value submitted and parsing it into the search string of the URL?
Any assistance would be appreciated. Cheers, JV
NOTE: As comment on your post says the likely issue is with the $qs variable, however here's an explanation of how you can get Query String values in Umbraco, for reference.
In Umbraco you can retrieve a Query string value in XSLT using umbraco.library
So to retrieve the value of search you would call something like:
<xsl:variable name="searchValue" select="umbraco.library:RequestQueryString('search')"/>
This creates a variable called searchValue which you can then use to re-inject the query string value in your url.
Something like this:
<a class="next" href="{concat('?page=', $page + 1, '&search=', $searchValue)}" title="Next page">›</a>
More information on umbraco.library can be found on the our.umbraco.org site.

Restart footnote numbering in each 'sect1' in Docbook

As the title describes my problem is that I want to reset the footnote numbering in each 'sect1', not just in each 'chapter' or 'appendix' and etc.
So far I couldn't manage to reset it. I've tried to copy a part of the footnote.xsl to my customization layer and change it but it didn't have any effect.
<xsl:template match="footnote" mode="footnote.number">
<xsl:choose>
<xsl:when test="string-length(#label) != 0">
<xsl:value-of select="#label"/>
</xsl:when>
<xsl:when test="ancestor::table or ancestor::informaltable">
<xsl:variable name="tfnum">
<xsl:number level="any" from="table|informaltable" format="1"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($table.footnote.number.symbols) >= $tfnum">
<xsl:value-of select="substring($table.footnote.number.symbols, $tfnum, 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:number level="any" from="table|informaltable"
format="{$table.footnote.number.format}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="fnum">
<!-- * Determine the footnote number to display for this footnote, -->
<!-- * by counting all foonotes, ulinks, and any elements that have -->
<!-- * an xlink:href attribute that meets the following criteria: -->
<!-- * -->
<!-- * - the content of the element is not a URI that is the same -->
<!-- * URI as the value of the href attribute -->
<!-- * - the href attribute is not an internal ID reference (does -->
<!-- * not start with a hash sign) -->
<!-- * - the href is not part of an olink reference (the element -->
<!-- * - does not have an xlink:role attribute that indicates it is -->
<!-- * an olink, and the hrf does not contain a hash sign) -->
<!-- * - the element either has no xlink:type attribute or has -->
<!-- * an xlink:type attribute whose value is 'simple' -->
<!-- * -->
<!-- * Note that hyperlinks are counted only if both the value of -->
<!-- * ulink.footnotes is non-zero and the value of ulink.show is -->
<!-- * non-zero -->
<!-- FIXME: list in #from is probably not complete -->
<xsl:number level="any"
from="chapter|appendix|preface|article|refentry|bibliography|sect1"
count="footnote[not(#label)][not(ancestor::table) and not(ancestor::informaltable)]
|ulink[$ulink.footnotes != 0][node()][#url != .][not(ancestor::footnote)][$ulink.show != 0]
|*[node()][#xlink:href][not(#xlink:href = .)][not(starts-with(#xlink:href,'#'))]
[not(contains(#xlink:href,'#') and #xlink:role = $xolink.role)]
[not(#xlink:type) or #xlink:type='simple']
[not(ancestor::footnote)][$ulink.footnotes != 0][$ulink.show != 0]
"
format="1"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="string-length($footnote.number.symbols) >= $fnum">
<xsl:value-of select="substring($footnote.number.symbols, $fnum, 1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:number value="$fnum" format="{$footnote.number.format}"/>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Well, I guess this is the rule for footnote numbering reset. As I tried to modify this part of 'footnote.xsl', it didn't work and the xsltproc returned with a bunch of errors.
Like this:
Undefined namespace prefix.
1 object left on the stack.