Expand my Community achievements bar.

Call JSON in a component that is specifically set on a page (not dinamically added in PARSYS).

Avatar

Former Community Member

Hi Guys,

We are building a really large site, and we need to set some fixed components within pages of a certain template.

The problem is that, within the included component, we need to make a json call for pagination purposes.

When we use a parsys, we use something like this to make the json calls:

 

<script>
    var currentNodePath = "<%= currentNode.getPath() %>";
    ...
</script>

<script>

 

    function loadMore(pageNumber){

        var baseURL = currentNodePath;

 

        $.ajax({

            url : baseURL + '.json',
            type: "POST",

     ....

</script>

 

The problem here is that the customer will need to create a really big number of pages ( > 500) and it can be tedious to configure each parsys and assign the component manually.

When we use a fixed include <cq:include path="INC" resourceType="CUSTOM_COMPONENT/> the call currentNode.getPath() does not work.

Is there any way to retrieve the actual path of the component outside a parsys so a json call can be used?

Thanks in advance.

2 Replies

Avatar

Former Community Member

Feike: thanks for your answer.

When I change currentNode.getPath() for resource.getPath() it still works when it's inside a parsys.

When the include is static, now it does not crash and even the URLS are similar, but strangely it does not reach the post.JSON.jsp servlet. It just returns a 200 http status but with html content:

<html><head>    <title>Content modified /content/.../jcr:content/interna_todos.json</title></head>    <body>    <h1>Content modified /content/.../jcr:content/interna_todos.json</h1>    <table>