rejetto forum
May 24, 2012, 02:05:35 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: This forum is free, you do NOT need to register to post. But you may.
PROBLEMS? QUESTIONS? CLICK HERE!
Fill the survey!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: counters  (Read 1894 times)
0 Members and 1 Guest are viewing this topic.
Flynsarmy
Experienced poster
***
Offline Offline

Afghanistan Afghanistan

Posts: 92


DENIED!


View Profile WWW
« on: January 14, 2007, 07:55:52 AM »

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...
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #1 on: January 16, 2007, 06:04:18 AM »

with "called" you mean substituted with the right number by the template system?
Logged
Flynsarmy
Experienced poster
***
Offline Offline

Afghanistan Afghanistan

Posts: 92


DENIED!


View Profile WWW
« Reply #2 on: January 17, 2007, 07:12:30 AM »

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
Logged
TSG
Operator
Insane poster
*****
Offline Offline

Australia Australia

Posts: 1919



View Profile WWW
« Reply #3 on: January 17, 2007, 07:35:27 AM »

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. Cheesy
Logged

Flynsarmy
Experienced poster
***
Offline Offline

Afghanistan Afghanistan

Posts: 92


DENIED!


View Profile WWW
« Reply #4 on: January 17, 2007, 08:29:46 AM »

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.
Logged
Giant Eagle
Insane poster
*****
Offline Offline

Netherlands Netherlands

Posts: 533


>=3 RAWR!

no.body056@gmail.com
View Profile WWW
« Reply #5 on: January 20, 2007, 07:01:22 AM »

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  Cheesy great idea!

 that would really solve the 'huge ID' problem
I really think this would help ppl with the same sort of problems Smiley
Logged

Rest in peace 500mhz server, you served me well...
New 1500mhz server DOA'ed on me >_>
New 2400mhz server up and running again Grin

rejetto forum
« Reply #5 on: January 20, 2007, 07:01:22 AM »

Do you like this software? Consider even $2
 Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #6 on: January 20, 2007, 07:20:41 AM »

is this a real problem?
Logged
Giant Eagle
Insane poster
*****
Offline Offline

Netherlands Netherlands

Posts: 533


>=3 RAWR!

no.body056@gmail.com
View Profile WWW
« Reply #7 on: January 20, 2007, 11:12:53 AM »

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
Logged

Rest in peace 500mhz server, you served me well...
New 1500mhz server DOA'ed on me >_>
New 2400mhz server up and running again Grin

rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #8 on: January 20, 2007, 02:03:04 PM »

that is... 1 second  Undecided

the to-do-list is very long, it seems a waste of time for now... doesn't it?
Logged
Ernad
Guest


Email
« Reply #9 on: September 20, 2009, 04:02:32 PM »

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.
Logged
Ernad
Guest


Email
« Reply #10 on: September 22, 2009, 02:41:48 AM »

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.
Logged
bacter
Operator
Insane poster
*****
Offline Offline

Spain Spain

Posts: 679


View Profile
« Reply #11 on: September 22, 2009, 03:50:59 AM »

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 you can find that with macros (macros only work with beta version of hfs) inc, dec and count you do not need any javascript.
Logged

your computer has no brain - use your own !
Ernad
Guest


Email
« Reply #12 on: September 22, 2009, 06:25:57 AM »

Thanks for the reference bacter! That's exactly what I needed Cheesy

I feel like such a noob now >_<
Logged
rejetto
Administrator
Insane programmer
*
Offline Offline

Italy Italy

Posts: 11829


View Profile
« Reply #13 on: September 23, 2009, 04:46:03 AM »

welcome Ernad!
don't worry, you did nothing bad
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!


Google visited last this page May 20, 2012, 07:05:16 AM