Creating a link to a sitemap item under a default matcher

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a link to a sitemap item under a default matcher

Wouter Danes-2

Hi all,

 

Is there anything in the Hippo API to create a link to a sitemap item under a _default_ matcher?
Something like HstLinkCreator#create(ResolvedSiteMapItem);

 

I can think of a way to do it myself using PathInfo, paramters and the sitemap path of the item, but there might be a function somewhere? J

 

Met vriendelijke groet / Yours sincerely,

 

---

Wouter Danes

Competence Manager Hippo / Java / Alfresco

Hinttech

 

T: +31 6 1158 8264

E: [hidden email]

@wouterdanes

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Creating a link to a sitemap item under a default matcher

Adolfo Benedetti
Hi Wouter,


Have you tried HstLinkCreator#create(ResolvedSiteMapItem, Mount) ?

Cheers,


--
Adolfo



2012/10/9 Wouter Danes <[hidden email]>

>
> Hi all,
>
>
>
> Is there anything in the Hippo API to create a link to a sitemap item under a _default_ matcher?
> Something like HstLinkCreator#create(ResolvedSiteMapItem);
>
>
>
> I can think of a way to do it myself using PathInfo, paramters and the sitemap path of the item, but there might be a function somewhere? J
>
>
>
> Met vriendelijke groet / Yours sincerely,
>
>
>
> ---
>
> Wouter Danes
>
> Competence Manager Hippo / Java / Alfresco
>
> Hinttech
>
>
>
> T: +31 6 1158 8264
>
> E: [hidden email]
>
> @wouterdanes
>
>
>
>
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Creating a link to a sitemap item under a default matcher

Adolfo Benedetti
Forget it, because the link can be ambiguous; when a wildcard is
encountered this method will return null :(

good luck!


Cheers,

Adolfo


2012/10/9 Adolfo Benedetti <[hidden email]>:

> Hi Wouter,
>
>
> Have you tried HstLinkCreator#create(ResolvedSiteMapItem, Mount) ?
>
> Cheers,
>
>
> --
> Adolfo
>
>
>
> 2012/10/9 Wouter Danes <[hidden email]>
>>
>> Hi all,
>>
>>
>>
>> Is there anything in the Hippo API to create a link to a sitemap item under a _default_ matcher?
>> Something like HstLinkCreator#create(ResolvedSiteMapItem);
>>
>>
>>
>> I can think of a way to do it myself using PathInfo, paramters and the sitemap path of the item, but there might be a function somewhere? J
>>
>>
>>
>> Met vriendelijke groet / Yours sincerely,
>>
>>
>>
>> ---
>>
>> Wouter Danes
>>
>> Competence Manager Hippo / Java / Alfresco
>>
>> Hinttech
>>
>>
>>
>> T: +31 6 1158 8264
>>
>> E: [hidden email]
>>
>> @wouterdanes
>>
>>
>>
>>
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Creating a link to a sitemap item under a default matcher

Wouter Danes-2
Exactly :)

I've got something like this now:

        ResolvedSiteMapItem resolvedSiteMapItem = requestContext.getResolvedSiteMapItem();
        String path = HstSiteMapUtils.getPath(siteMapItem);
        int parameterIndex = 1;
        while (path.contains("_default_")) {
            String replacement = resolvedSiteMapItem.getParameter(createPropertyPlaceHolder(parameterIndex));
            path = StringUtils.replaceOnce(path, "_default_", replacement);
            parameterIndex++;
        }

Then I can do create(path, mount) and stuff should work. :)

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Adolfo Benedetti
Sent: dinsdag 9 oktober 2012 15:17
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] Creating a link to a sitemap item under a default matcher

Forget it, because the link can be ambiguous; when a wildcard is encountered this method will return null :(

good luck!


Cheers,

Adolfo


2012/10/9 Adolfo Benedetti <[hidden email]>:

> Hi Wouter,
>
>
> Have you tried HstLinkCreator#create(ResolvedSiteMapItem, Mount) ?
>
> Cheers,
>
>
> --
> Adolfo
>
>
>
> 2012/10/9 Wouter Danes <[hidden email]>
>>
>> Hi all,
>>
>>
>>
>> Is there anything in the Hippo API to create a link to a sitemap item under a _default_ matcher?
>> Something like HstLinkCreator#create(ResolvedSiteMapItem);
>>
>>
>>
>> I can think of a way to do it myself using PathInfo, paramters and
>> the sitemap path of the item, but there might be a function
>> somewhere? J
>>
>>
>>
>> Met vriendelijke groet / Yours sincerely,
>>
>>
>>
>> ---
>>
>> Wouter Danes
>>
>> Competence Manager Hippo / Java / Alfresco
>>
>> Hinttech
>>
>>
>>
>> T: +31 6 1158 8264
>>
>> E: [hidden email]
>>
>> @wouterdanes
>>
>>
>>
>>
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Creating a link to a sitemap item under a default matcher

Wouter Danes-2
Here's the actual code that I was working at: Breadcrumb elements for sitemap items that don't have a related content bean.
This code does the trick, but it's a bit messy to have it here..

    private static BreadCrumbElementBean createBreadCrumbElementBasedOnStaticSiteMapItem(
            HstRequestContext requestContext, HstSiteMapItem siteMapItem, boolean isCurrent) {

        HstLinkCreator linkCreator = requestContext.getHstLinkCreator();
        ResolvedSiteMapItem resolvedSiteMapItem = requestContext.getResolvedSiteMapItem();
        String path = HstSiteMapUtils.getPath(siteMapItem);
        int parameterIndex = 1;
        while (path.contains("_default_")) {
            String replacement = resolvedSiteMapItem.getParameter(String.valueOf(parameterIndex));
            path = StringUtils.replaceOnce(path, "_default_", replacement);
            parameterIndex++;
        }
        String lookUpKey = getLookUpKeyForStaticBreadCrumbItem(siteMapItem.getValue());
        String title = getConstant(lookUpKey);
        HstLink link = linkCreator.create(path, requestContext.getResolvedMount().getMount());
        String url = link.toUrlForm(requestContext, false);

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Creating breadcrumb with title = '{}' and url = '{}'", title, url);
        }

        return new BreadCrumbElementBean(title, url, isCurrent);
    }

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Wouter Danes
Sent: dinsdag 9 oktober 2012 15:22
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] Creating a link to a sitemap item under a default matcher

Exactly :)

I've got something like this now:

        ResolvedSiteMapItem resolvedSiteMapItem = requestContext.getResolvedSiteMapItem();
        String path = HstSiteMapUtils.getPath(siteMapItem);
        int parameterIndex = 1;
        while (path.contains("_default_")) {
            String replacement = resolvedSiteMapItem.getParameter(createPropertyPlaceHolder(parameterIndex));
            path = StringUtils.replaceOnce(path, "_default_", replacement);
            parameterIndex++;
        }

Then I can do create(path, mount) and stuff should work. :)

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Adolfo Benedetti
Sent: dinsdag 9 oktober 2012 15:17
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] Creating a link to a sitemap item under a default matcher

Forget it, because the link can be ambiguous; when a wildcard is encountered this method will return null :(

good luck!


Cheers,

Adolfo


2012/10/9 Adolfo Benedetti <[hidden email]>:

> Hi Wouter,
>
>
> Have you tried HstLinkCreator#create(ResolvedSiteMapItem, Mount) ?
>
> Cheers,
>
>
> --
> Adolfo
>
>
>
> 2012/10/9 Wouter Danes <[hidden email]>
>>
>> Hi all,
>>
>>
>>
>> Is there anything in the Hippo API to create a link to a sitemap item under a _default_ matcher?
>> Something like HstLinkCreator#create(ResolvedSiteMapItem);
>>
>>
>>
>> I can think of a way to do it myself using PathInfo, paramters and
>> the sitemap path of the item, but there might be a function
>> somewhere? J
>>
>>
>>
>> Met vriendelijke groet / Yours sincerely,
>>
>>
>>
>> ---
>>
>> Wouter Danes
>>
>> Competence Manager Hippo / Java / Alfresco
>>
>> Hinttech
>>
>>
>>
>> T: +31 6 1158 8264
>>
>> E: [hidden email]
>>
>> @wouterdanes
>>
>>
>>
>>
>> _______________________________________________
>> Hippo-cms7-user mailing list and forums
>> http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html