1

We need to use a source query for the General Link field type to display only the current page's data. In Sitecore XM Clould, is there any way we can achieve it from the front code (NextJs) as the source query is not working from the Sitecore?

e.g Below query

query:./*[@@templatename='Page Data']

Further, we need to restrict the Link field type to the Internal Field Type.

Is there any way this can be achieved (if not from Sitecore, from the front end in the component's logic)?

Thanks, Shrutika

2 Answers 2

3

You can use a query like this to get the children Items of a specific type(You can change the query according to your need). Additionally provide a help text for the Content Authors to use internal link option. enter image description here

query:self:://*[@@templatename='MY PAGE']

In the frontend site you can add a filter to check the linktype and if it is internal link then only display. Like following:

{CTA?.value?.href && CTA?.value?.linktype === 'internal' && (
                <Link
                  field={CTA}
                /> // Please use your logic to render the Link
              )}
2

You can check the link type by navigating deep in the props and looking for the link field in addition to the link type you will get more details.

depending on props and field name your code might look like

link?.value?.linktype == 'internal'/external' ? 'Do something': 'Do nothing';

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.