found as solution to translate %item-index%, %number-folders%, %number-files%, %number-links% at same stage
this answer your question: "Did you try to use {.=|%item-number%|%number-folders%.} ?"
NOW WORKING:
function Tmainfrm.getFolderPage(folder:Tfile; cd:TconnData; otpl:Tobject):string;
// we pass the Tpl parameter as Tobject because symbol Ttpl is not defined yet
var
baseurl, list, fileTpl, folderTpl, linkTpl: string;
table: TStringDynArray;
ofsRelItemUrl, ofsRelUrl, numberFiles, numberFolders, numberLinks: integer;
indexFiles, indexFolders, indexLinks: integer;
img_file: boolean;
totalBytes: int64;
fast: TfastStringAppend;
buildTime: Tdatetime;
listing: TfileListing;
diffTpl: Ttpl;
isDMbrowser: boolean;
hasher: Thasher;
fullEncode, recur, oneAccessible: boolean;
md: TmacroData;
procedure applySequential();
const
PATTERN = '%sequential%';
var
idx, p: integer;
idxS: string;
begin
idx:=0;
p:=1;
repeat
p:=ipos(PATTERN, result, p);
if p = 0 then exit;
inc(idx);
idxS:=intToStr(idx);
delete(result, p, length(PATTERN)-length(idxS));
move(idxS[1], result[p], length(idxS));
until false;
end; // applySequential
procedure handleItem(f:Tfile);
var
type_, s, url, fingerprint, itemFolder: string;
nonPerc: TStringDynArray;
begin
if not f.isLink and ansiContainsStr(f.resource, '?') then exit; // unicode filename? //mod by mars
if f.size > 0 then inc(totalBytes, f.size);
// build up the symbols table
md.table:=NIL;
nonPerc:=NIL;
if f.icon >= 0 then
begin
s:='~img'+intToStr(f.icon);
addArray(nonPerc, ['~img_folder', s, '~img_link', s]);
end;
if f.isFile() then
if img_file and (useSystemIconsChk.checked or (f.icon >= 0)) then
addArray(nonPerc, ['~img_file', '~img'+intToStr(f.getSystemIcon())]);
if recur or (itemFolder = '') then
itemFolder:=optUTF8(diffTpl, f.getFolder());
if recur then
url:=substr(itemFolder, ofsRelItemUrl)
else
url:='';
addArray(md.table, [
'%item-folder%', itemFolder,
'%item-relative-folder%', url
]);
if not f.accessFor(cd) then
s:=diffTpl['protected']
else
begin
s:='';
if f.isFileOrFolder() then
oneAccessible:=TRUE;
end;
addArray(md.table, [
'%protected%', s
]);
// url building
fingerprint:='';
if fingerprintsChk.checked and f.isFile() then
begin
s:=loadMD5for(f.resource);
if s = '' then s:=hasher.getHashFor(f.resource);
if s > '' then fingerprint:='#!md5!'+s;
end;
if f.isLink() then
begin
url:=f.resource;
s:=url;
end
else
if pwdInPagesChk.Checked and (cd.usr > '') then
begin
if encodePwdUrlChk.checked then s:=totallyEncoded(cd.pwd)
else s:=encodeURL(cd.pwd);
s:=f.fullURL( encodeURL(cd.usr)+':'+s, getSafeHost(cd) )+fingerprint;
url:=s
end
else
begin
if recur then
s:=copy(f.url(fullEncode), ofsRelUrl, MAXINT)+fingerprint
else
s:=f.relativeURL(fullEncode)+fingerprint;
url:=baseurl+s;
end;
if not f.isLink() then
begin
s:=macroQuote(s);
url:=macroQuote(url);
end;
addArray(md.table, [
'%item-url%', s,
'%item-full-url%', url
]);
// select appropriate template
if f.isLink() then
begin
s:=linkTpl;
inc(indexLinks);
type_:='link';
end
else if f.isFolder() then
begin
s:=folderTpl;
inc(indexFolders);
type_:='folder';
end
else
begin
s:=diffTpl.getTxtByExt(ExtractFileExt(f.name));
if s = '' then s:=fileTpl;
inc(indexFiles);
type_:='file';
end;
addArray(md.table, [
'%number-files%', intToStr(numberFiles),
'%number-folders%', intToStr(numberFolders),
'%number-links%', intToStr(numberlinks),
'%number%', inttostr(numberFiles+numberFolders+numberlinks),
'%item-index%', inttostr(if_(type_='file',indexFiles)+if_(type_='link',indexLinks)+if_(type_='folder',indexFolders)), //add by mars
'%item-number%', inttostr(indexFiles+indexLinks+indexFolders), //add by mars replace usage of limited %sequential%
'%item-type%', type_
]);
s:=xtpl(s, nonPerc);
md.f:=f;
tryApplyMacrosAndSymbols(s, md, FALSE);
fast.append(s);
end; // handleItem
var
i: integer;
begin
result:='';
if (folder = NIL) or not folder.isFolder() then exit;
if macrosLogChk.checked and not appendmacroslog1.checked then
resetLog();
diffTpl:=Ttpl.create();
folder.lock();
try
buildTime:=now();
cd.conn.addHeader('Cache-Control: no-cache, no-store, must-revalidate, max-age=-1');
recur:=shouldRecur(cd);
baseurl:=protoColon()+getSafeHost(cd)+folder.url(TRUE);
if cd.tpl = NIL then
diffTpl.over:=otpl as Ttpl
else
begin
diffTpl.over:=cd.tpl;
cd.tpl.over:=otpl as Ttpl;
end;
if otpl <> filelistTpl then
diffTpl.fullText:=optUTF8(diffTpl.over, folder.getRecursiveDiffTplAsStr());
isDMbrowser:= otpl = dmBrowserTpl;
fullEncode:=not isDMbrowser;
ofsRelUrl:=length(folder.url(fullEncode))+1;
ofsRelItemUrl:=length(optUTF8(diffTpl, folder.pathTill()))+1;
// pathTill() is '/' for root, and 'just/folder', so we must accordingly consider a starting and trailing '/' for the latter case (bugfix by mars)
if not folder.isRoot() then
inc(ofsRelItemUrl, 2);
fillChar(md, sizeOf(md), 0);
md.cd:=cd;
md.tpl:=diffTpl;
md.folder:=folder;
md.archiveAvailable:=folder.hasRecursive(FA_ARCHIVABLE) and not folder.isDLforbidden();
md.hideExt:=folder.hasRecursive(FA_HIDE_EXT);
result:=diffTpl['special:begin'];
tryApplyMacrosAndSymbols(result, md, FALSE);
// cache these values
fileTpl:=xtpl(diffTpl['file'], table);
folderTpl:=xtpl(diffTpl['folder'], table);
linkTpl:=xtpl(diffTpl['link'], table);
// this may be heavy to calculate, only do it upon request
img_file:=pos('~img_file', fileTpl) > 0;
// build %list% based on dir[]
numberFolders:=0; numberFiles:=0; numberLinks:=0;
indexLinks:=0; indexFolders:=0; indexFiles:=0;
totalBytes:=0;
oneAccessible:=FALSE;
fast:=TfastStringAppend.Create();
listing:=TfileListing.create();
hasher:=Thasher.create();
hasher.loadFrom(folder.resource);
try
listing.fromFolder( folder, cd, recur );
listing.sort(cd, if_(recur or (otpl = filelistTpl), '?', diffTpl['sort by']) ); // '?' is just a way to cause the sort to fail in case the sort key is not defined by the connection
for i:=0 to length(listing.dir)-1 do
if listing.dir[i].isLink() then inc(numberLinks)
else if ansiContainsStr(listing.dir[i].resource, '?') then continue
else if listing.dir[i].isFolder() then inc(numberFolders)
else inc(numberFiles);
for i:=0 to length(listing.dir)-1 do
begin
application.ProcessMessages();
if cd.conn.state = HCS_DISCONNECTED then exit;
cd.lastActivityTime:=now();
handleItem(listing.dir[i])
end;
list:=fast.reset();
finally
listing.free;
fast.free;
hasher.free;
end;
if cd.conn.state = HCS_DISCONNECTED then exit;
// build final page
if not oneAccessible then md.archiveAvailable:=FALSE;
md.table:=toSA([
'%number-files%', intToStr(numberFiles),
'%number-folders%', intToStr(numberFolders),
'%number-links%', intToStr(numberlinks),
'%number%', inttostr(numberFiles+numberFolders+numberlinks),
'%upload-link%', if_(accountAllowed(FA_UPLOAD, cd, folder), diffTpl['upload-link']),
'%files%', if_(list='', diffTpl['nofiles'], diffTpl['files']),
'%list%',list,
'%total-bytes%', intToStr(totalBytes),
'%total-kbytes%', intToStr(totalBytes div KILO),
'%total-size%', smartsize(totalBytes)
]);
result:=diffTpl[''];
md.f:=NIL;
md.afterTheList:=TRUE;
try tryApplyMacrosAndSymbols(result, md)
finally md.afterTheList:=FALSE end;
applySequential();
// ensure this is the last symbol to be translated
result:=xtpl(result, [
'%build-time%', floatToStrF((now()-buildTime)*SECONDS, ffFixed, 7,3)
]);
finally
folder.unlock();
diffTpl.free;
end;
end; // getFolderPage
PS: those lines are necessary for two different places
'%number-files%', intToStr(numberFiles),
'%number-folders%', intToStr(numberFolders),
'%number-links%', intToStr(numberlinks),
'%number%', inttostr(numberFiles+numberFolders+numberlinks),
and the part of tpl
[file=folder=link|private]
<tr class='{.if|{.mod|{.count|row.}|2.}|even.}'><td>
%item-number%/%number% {.if |{.=|%item-number%|%number%.}|(last item )|(not last item).} -- %item-index%/{.switch|%item-type%|;|folder|%number-folders%|link|%number-links%|file|%number-files%.} {.if|{.=|%item-index%|{.switch|%item-type%|;|folder|%number-folders%|link|%number-links%|file|%number-files%.} .}|(last %item-type%)|(not last %item-type%).}
<input type='checkbox' class='selector' name='selection' value='%item-url%' {.if not|{.or|{.get|can delete.}|{.get|can access.}|{.get|can archive item.}.}|disabled='disabled'.} />
{.if|{.get|is new.}|<span class='flag'> NEW </span>.}
{.if not|{.get|can access.}|<img src='/~img_lock'>.}
<a href="%item-url%"><img src="%item-icon%"> %item-name%</a>
{.if| {.?search.} |{:{.123 if 2|<div class='item-folder'>{.!item folder.} |{.breadcrumbs|{:<a href="%bread-url%">%bread-name%/</a>:}|from={.count substring|/|%folder%.}/breadcrumbs.}|</div>.}:} .}
{.123 if 2|<div class='comment'>|{.commentNL|%item-comment%.}|</div>.}
[+file]
<td>%item-size%B<td>%item-modified%<td>%item-dl-count%
[+folder]
<td class='nosize'>folder<td>%item-modified%<td>%item-dl-count%
[+link]
<td class='nosize'>link<td colspan='2'>