2

I need the list of all the references present across all the publications for a page.

I am getting this information using PageURLCriteria: PageURLCriteria criteria= new PageURLCriteria("%" + URL, Criteria.LIKE);

It works well, if the URL is "/test/index.jsp" or "/some/index.jsp" where I get all the exact references of index.jsp from other publications.

Problem comes when I have the URL pattern as "/index.jsp" where query returns the results in thousands as it search all the "/index.jsp" from all the publications.

I have the TCM Id of my page, cant I get the list of TCM Id for this page present in other publications too?

Or any other way through which I get the references of page in other publication.

Also, I want to achieve it usiug broker query through content delivery API, I know ODATA can provide me that but somehow I can't use that.

Thanks

  • You question is not much clear, what you want to achieve actually. Why do you want page tcm-id reference from other publications? – Raj Kumar Feb 18 '16 at 5:05
  • Hi Raj, I want to get the reference of all the pages created across all publications to generate alternate URLs for a given page. – Yash Feb 18 '16 at 8:32
  • so Like criteria is the reason you are getting all results in case of /index. you should avoid like. – Raj Kumar Feb 18 '16 at 8:39
  • I know I have to avoid LIKE and that is why I crated the post to know the alternate solution to get all the TCM references for a page based on the TCM ID or the relative URL of the given page. – Yash Feb 18 '16 at 9:02
4

It's not clear what you want to achieve with the queries, but taking into account the information that you provide, if you want to obtain the list of pages with same id (in this example is 46, change as your needs) in vatrious publications, the way is as follows, using the ItemReferenceCriteria:

<%
//Create query
    Query myQuery = new Query();
    Criteria myCriteria = null;
    //Page Id = 46
    ItemReferenceCriteria itemReferenceCriteria = new ItemReferenceCriteria(46);
    //Page Type
    ItemTypeCriteria itemTypeCriteria = new ItemTypeCriteria(64);
    AndCriteria andCriteria = new AndCriteria(itemReferenceCriteria, itemTypeCriteria);
    myQuery.setCriteria(andCriteria);

    String[] itemURIs = myQuery.executeQuery();
    for (int i = 0; i < itemURIs.length; i++) {
        %>
        <p><%=itemURIs[i]%></p>
        <%
    } 
%>

The result is the uri's of the pages with same ID.

  • Thanks a lot Raul..It worked, that is what I was looking for. – Yash Feb 18 '16 at 9:08
  • If the answer fits the question, it is good practice to mark the question as "answered" to serve as a reference Q&A for other users. Also identify yourself is a good practice, as this is a community of people not id's. – Raúl Escudero Feb 18 '16 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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