Add device context (mobile/tablet/desktop) to //udt:Context for XSLT templates #116
alonsohdez
started this conversation in
General
Replies: 1 comment
-
I won't object if a PR comes in for that, but I believe modern development should just handle differences using frontend technologies. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
While working with F&L (UDT 6.5.8) and custom XSLT templates, I noticed that the //udt:Context node already provides very useful values such as CurrentCulture, ModuleId, OrderBy, etc. However, there is currently no way to detect the type of client device (mobile, tablet, or desktop) directly in XSLT.
Suggestion:
Extend the Context table so that it also exposes the client capability information from DNN’s built-in ClientCapabilityProvider. For example:
<udt:Context>
<udt:Device>mobile</udt:Device>
<udt:IsMobile>true </udt:IsMobile>
<udt:IsTablet>false </udt:IsTablet>
</udt:Context>
Benefits:
Template authors could conditionally render content for different device types directly in XSLT, without needing wrapper modules or custom extension objects.
It keeps the approach consistent with existing context values such as CurrentCulture.
Very little code is required: simply enrich the Context dataset before the XSL transformation with values from ClientCapabilityProvider.CurrentClientCapability.
Example usage in XSL:
<xsl:if test="//udt:Context/udt:IsMobile='true'">
</xsl:if>
<xsl:variable name="device" select="//udt:Context/udt:Device"/>
I believe this would be a small but valuable improvement to the module and would simplify responsive scenarios for many users.
What do you think about including this enhancement in a future release?
Beta Was this translation helpful? Give feedback.
All reactions