SearchPagingNext

    Table of contents
    No headers
    /**
     * Search Paging Control
     *
     * @param uri $uri - base uri (default: page.uri)
     * @param map $params - query params to preserve
     * @param num $showing - number of visible results
     * @param bool $next - are there more results?
     * @param num $perPage - number of results shown per page (default: 10)
     * @param str $key - query param to use for paging (default: "page")
     * @param num $page - current page being viewed (default: __request.args[$key])
     * @param str $showingKey - custom resource key to use for "showing results"
     */
    var uri = $uri ?? page.uri;
    var params = $params; // required!
    var showing = $showing; // required!
    var nextPage = $next ?? false;
    var perPage = $perPage ?? 10;
    var pageKey = $key ?? "page";
    var currentPage = $page ?? __request.args[pageKey];
    var localizeShowing = $showingKey ?? "MindTouch.Reports.paging.results";
    
    // compute paging
    if (!currentPage || currentPage < 1) {
        let currentPage = 1;
    }
    
    var setStart = (currentPage - 1) * perPage;
    var setEnd = setStart + showing;
    
    <form class="mt-search-paging" method="get" action=(uri)>
        foreach (var paramName:paramValue in params where paramName != pageKey) {
            <input type="hidden" name=(paramName) value=(paramValue) />
        }
        <div class="summary">
            if (showing < 1) {
                wiki.localize("MindTouch.Reports.paging.noresults");
            } else {
                wiki.localize(localizeShowing, [
                    (setStart+1),
                    setEnd
                ]);
            }
        </div>
        <div class="paging">
            if (currentPage > 1) {
                <span class="prev">
                    <a href=( uri & (params .. {(pageKey): (currentPage - 1)}) )>
                        wiki.localize("MindTouch.Reports.paging.prev");
                    </a>
                </span>
            } else {
                <span class="prev ui-state-disabled">wiki.localize("MindTouch.Reports.paging.prev")</span>
            }
    
            <span class="jump">wiki.localize("MindTouch.Reports.paging.jump")</span>
            <input class="jump" type="text" name=(pageKey) value=(currentPage) size="2" />
    
            if (nextPage) {
                <span class="next">
                    <a href=( uri & (params .. {(pageKey): (currentPage + 1)}) )>
                        wiki.localize("MindTouch.Reports.paging.next");
                    </a>
                </span>
            } else {
                <span class="next ui-state-disabled">wiki.localize("MindTouch.Reports.paging.next")</span>
            }
        </div>
    </form>
    
    
    
    
    Tag page (Edit tags)
    • No tags
    You must login to post a comment.
    Powered by MindTouch Core