<!--parser:xtscript-->
# Set the filter to exclude index files
var $filter= -index*
# Get the list of sub-folders
var $folder_list = <xt:filelist sort_type="name" sort_dir="asc" folder="/Page" template="|.file_url." per_page="" filter="$filter"/>|
# Convert the absolute links to relative links
var $remove = <xt:url type="domain">
var $remove = http://$remove
var $folder_list = call str_ireplace $subject=$folder_list; $search=$remove; $replace
# Get the length of the sub-folder list
var $length = call strlen $val=$folder_list
# Set the start pointer
var $start=1
# Set the outer holder
print <div class="xt_list">
# The main loop
@loop
# Find the end of the current entry
var $end = call strpos $haystack=$folder_list;$needle=|;$offset=($start+1);
# Get the path to the sub-folder
var $subpath = call substr $val=$folder_list;$start=($start+1);$length=($end-$start-1)
# Count the files in the sub-folder
var $subcount = <xt:filelist sort_type="name" sort_dir="asc" folder="/$subpath" template="." per_page="" filter="$filter"/>
var $subcount = call strlen $val=$subcount
#Extract the sub folders name from the sub folders path
var $sub_link_text=call strrpos $haystack=$subpath;$needle=/
var $sub_link_text=call substr $val=$subpath;$start=($sub_link_text+1)
# Output a link to the sub-folders index with a count of the files
print <a class="xt_blog_title_link" href="/$subpath/"> <b>$sub_link_text </b><span style="float:right">($subcount Files)</span></a><br />
# Add the count to the total
var $total = ($total+$subcount)
# Move the pointer to the start of the next entry
var $start = ($end+1)
# If we are not at the end of the list of sub-folders loop back
if not $start >= $length
goto @loop
endif
#Output the total file count
print <span class="xt_button">Total Files = $total</span></div>
<!--/parser:xtscript-->