counting pages

steelej's Avatar

steelej

09 May, 2012 01:59 PM

We have a student employmnet site to list jobs by department.
Each job listing is a page withing a dept. directory.
I index all the directories and grab the title and path to their index pages to output a list of links.

I've been asked if it's possible to include in that list the number of open jobs in each dept. directory (there is a node for "open" with a value of "Yes" if it is).

Instead of just a list of links:

Admissions
Alumni
Annual-fund

They want:

Admissions (2)
Alumni (1)
etc.

Any suggestions as to how to go about this?

The current script and block xml are attached.

  1. Support Staff 2 Posted by Charlie Holder on 09 May, 2012 02:16 PM

    Charlie Holder's Avatar

    This should be close to what you're looking for:

    ## This chooses only folders that have jobs
    #set ( $depts = $_XPathTool.selectNodes($contentRoot, "/system-index-block/system-folder[system-page[name!='index']]") )
    
    <h6>Current Jobs</h6>
    <ul class="columnnav">
        <li>
            <strong><a href="site://ssc/student-employment/index">Student Employment Home</a></strong>
        </li>
    #foreach ( $dept in $depts )
        ## Link to that Department's landing page
        #set ( $land  = $_XPathTool.selectSingleNode($dept, "system-page[name='index']/link").value )
        ## Size of array, the number of postings in that Department
        #set ( $jobs  = $_XPathTool.selectNodes($dept, "system-page[name!='index']").size() )
        ## Title of the Department Folder landing page
        ## Change this to access the $dept variable if you want to pull the folder title
        #set ( $title = $_XPathTool.selectSingleNode($dept, "system-page[name='index']/title") )
        
        #if ( $dept.getAttribute("current") )
            #set ( $curr = "current" )
        #else
            #set ( $curr = "" )
        #end
        
        <li>
            <a href="${land}" class="${curr}">$_EscapeTool.xml($title.value)</a> (${jobs})
        </li>
    #end
    </ul>
    
  2. Support Staff 3 Posted by Charlie Holder on 09 May, 2012 02:27 PM

    Charlie Holder's Avatar

    Update: added comments to the above code so it's more clear what's going on.

  3. 4 Posted by steelej on 09 May, 2012 03:05 PM

    steelej's Avatar

    Charlie,
    This is great. I added in the "open" switch so it only counts open positions. Thanks too for the comments.

    We're up and running.

    Jim

  4. steelej closed this discussion on 09 May, 2012 03:06 PM.

Comments are currently closed for this discussion. You can start a new one.