Get Sub-string From URL in FTL

10 vues
Accéder directement au premier message non lu

Vivek

non lue,
20 févr. 2018, 08:31:3620/02/2018
à Hippo Community
Hi,

I have the below URL string say /level1/level2/level3/_________________

Now I need to get the sub-string till level 3. i.e. /level1/level2/level3 . How can I achieve it?

Thanks,

Jasper Floor

non lue,
20 févr. 2018, 09:09:4820/02/2018
à Hippo Community
Get the URL (from the request) and do a regex match. 

mvg,
Jasper

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Woonsan Ko

non lue,
20 févr. 2018, 10:56:5420/02/2018
à hippo-c...@googlegroups.com
<#assign s="/level1/level2/level3/a/b/c.html">
<#assign res=s?matches(r"^(\/[^\/]+){3}(.*)$")>
<#assign remaining="">
<#if res>
  <#assign remaining=res?groups[1]>
</#if>
${remaining} <#-- "/a/b/c.html" -->

Regards,

Woonsan

References:
 

Thanks,

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-community@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

Woonsan Ko

non lue,
20 févr. 2018, 10:57:5720/02/2018
à hippo-c...@googlegroups.com
On Tue, Feb 20, 2018 at 10:56 AM, Woonsan Ko <woons...@bloomreach.com> wrote:


On Tue, Feb 20, 2018 at 8:31 AM, Vivek <vivek....@gmail.com> wrote:
Hi,

I have the below URL string say /level1/level2/level3/_________________

Now I need to get the sub-string till level 3. i.e. /level1/level2/level3 . How can I achieve it?

<#assign s="/level1/level2/level3/a/b/c.html">
<#assign res=s?matches(r"^(\/[^\/]+){3}(.*)$")>
<#assign remaining="">
<#if res>
  <#assign remaining=res?groups[1]>
Sorry, it should be 'res?groups[2]'.

Woonsan

Vivek

non lue,
22 févr. 2018, 00:16:2722/02/2018
à Hippo Community
Hi, I do need last url, I need parent URL till 3 level. say /level1/leve2/level3


On Tuesday, February 20, 2018 at 9:27:57 PM UTC+5:30, woonsan.ko wrote:
On Tue, Feb 20, 2018 at 10:56 AM, Woonsan Ko <woons...@bloomreach.com> wrote:


On Tue, Feb 20, 2018 at 8:31 AM, Vivek <vivek....@gmail.com> wrote:
Hi,

I have the below URL string say /level1/level2/level3/_________________

Now I need to get the sub-string till level 3. i.e. /level1/level2/level3 . How can I achieve it?

<#assign s="/level1/level2/level3/a/b/c.html">
<#assign res=s?matches(r"^(\/[^\/]+){3}(.*)$")>
<#assign remaining="">
<#if res>
  <#assign remaining=res?groups[1]>
Sorry, it should be 'res?groups[2]'.

Woonsan
 
 

Thanks,

--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.

Woonsan Ko

non lue,
22 févr. 2018, 09:11:5522/02/2018
à hippo-c...@googlegroups.com
<#assign s="/level1/level2/level3/a/b/c.html">
<#assign res=s?matches(r"^((\/[^\/]+){3})(.*)$")>
<#assign firstThree="">
<#if res>
  <#assign firstThree=res?groups[1]>
</#if>
${firstThree} <#-- "/level1/level2/level3" -->


To post to this group, send email to hippo-community@googlegroups.com

RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-community+unsubscribe@googlegroups.com.

Woonsan Ko

non lue,
22 févr. 2018, 10:01:4522/02/2018
à hippo-c...@googlegroups.com
Also, for those who want to test FreeMarker templates on the fly, try this at any time with the examples:

Cheers,

Woonsan

Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message