rejetto forum
Software => HFS ~ HTTP File Server => Topic started by: Flynsarmy on January 14, 2007, 01:55:52 PM
-
Would it be possible to add some number of counter variables? Eg
%counter1%, %counter2% etc. They start at 0 and increase by 1
each time they are called on the page.
This would be extremely useful for creating a unique identifier inside
each cell of the file table. We are currently using %file-name% but
that contains spaces and can get very long, especially for something
like an id...
-
with "called" you mean substituted with the right number by the template system?
-
Each time %counter1% appears in the page code, HFS will increase the counter by 1
and return the counter.
For example:
%counter1%<br/>%counter1%<br/>%counter1%<br/>%counter1%<br/>%counter1%
will print:
0
1
2
3
4
-
So the basic idea is the number can be used in place of the file name in the file list, so instead of id="WOOOO_ITS_THE_FIRST_FILE_FILENAME.mp3" we can use id="0", the lookup for the mp3player will be quicker, according to flynsarmy. :D
-
It's not that the mp3 player lookup would be quicker, it's that ID tags would be
ALOT less redundant. Instead of having a huge filename as an id (which may
even contain spaces, and i'm not sure how different browsers handle spaces in
ID's), you can just have a counter value. It would increase page load time.
-
Each time %counter1% appears in the page code, HFS will increase the counter by 1
and return the counter.
For example:
%counter1%<br/>%counter1%<br/>%counter1%<br/>%counter1%<br/>%counter1%
will print:
0
1
2
3
4
yea :D great idea!
that would really solve the 'huge ID' problem
I really think this would help ppl with the same sort of problems :)
-
is this a real problem?
-
is this a real problem?
For ppl with low bandwith, i think it does actually..
the difference: Id="1" or Id="average file name length goes here.mp3"
Each id will be used atleast 2 times to make a function work. If you have, for example, 50 files in a folder.. It would reduce the template size with +/- 3.5kb
-
that is... 1 second :-\
the to-do-list is very long, it seems a waste of time for now... doesn't it?
-
I realize that this topic hasn't been replied to in ages, but I'll post this almost-solution in case someone else needs it. A counter can easily be created by using javascript.
How to count number of list-items:
//This goes in the <head> section of the page
<script type="javascript">var item_counter = 0;</script>
//If you for example want to count number of mp3 files put this in section [file.mp3]
<script type="javascript">item_counter += 1;</script>
//Then place the following inside section [file.mp3] where you want to output the count-number
<script type="javascript">document.write(item_counter);</script>
However, since the original question was to have short and unique id's instead of using long filenames, I would suggest using %item-size-b% (filesize in bytes). It will output something like "45321564". Since you rarely have two files that are identical in byte-size, I think you won't have any problems with duplicate id's with this solution.
-
Hello there Mars! Sorry, I'm new to the forum. I did in fact look around in the forum for quite some time, but I couldn't find any solution for this problem. If you know of posts that have already answered this, please provide a link.
I'm not sure how the variables you provided can solve my problem. According to another post (http://www.rejetto.com/forum/index.php?topic=1939.0) they give the same value for all the files in the current folder. E.g. if there are 5 files the variable %number-files% would output 5, and not 1 for file#1, 2 for file#2, 3 for file#3, etc.... One would still have to create a JS loop to iterate the number.
-
Ernad: looking around you should have found something called macros. Looking at the list of available macros on http://www.rejetto.com/wiki/index.php/HFS:_scripting_commands (http://www.rejetto.com/wiki/index.php/HFS:_scripting_commands) you can find that with macros (macros only work with beta version of hfs) inc, dec and count you do not need any javascript.
-
Thanks for the reference bacter! That's exactly what I needed :D
I feel like such a noob now >_<
-
welcome Ernad!
don't worry, you did nothing bad