Zum Hauptinhalt gehen

Script to iterate over sitestore

Kommentare

1 Kommentar

  • Zendesk API User
    Author: gockel - 8/19/2010 10:44

    Hi,

    i would prefer to use the reference graph information to avoid iteration over the sitestore.

    import de.espirit.firstspirit.access.store.Store;
    import de.espirit.firstspirit.access.store.sitestore.PageRef;
    import de.espirit.firstspirit.access.store.templatestore.Query;
    import de.espirit.firstspirit.access.ReferenceEntry;

    // UID of the query
    QUERY_UID = "Products.products_1";

    templateStore = context.getUserService().getStore(Store.Type.TEMPLATESTORE, false);
    query = templateStore.getStoreElement(QUERY_UID, Query.UID_TYPE);
    if (query == null) {
        context.logError("query not found");
        return;
    }


    // find all objects using the query
    incomingRefs = query.getIncomingReferences();
    for (ref : incomingRefs) {

        // is it a sitestore reference
        if (ref.isType(ReferenceEntry.SITE_STORE_REFERENCE)) {
            element = ref.getReferencedElement();   
            if (element != null && element instanceof PageRef) {
                cParams = element.getContent2Params();
                if (cParams != null) {
                    catParam = cParams.getFilterParams().get("category");
                    if (catParam != null && catParam.equals(1088)) {
                        context.logInfo("pageref found - " + element.getUid() + "(ID=" + element.getId() + ")");
                    }
                }
            }
        }
    }

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.