Gossamer Forum
Home : Products : Links 2.0 : Customization :

page size

Quote Reply
page size
Can you tel me how can I get link page size

like this way

Last modified on: 1-Jan-1970 - 2K bytes

Quote Reply
Re: page size In reply to
Use SSI:

The config directive controls various aspects of file parsing, and allows you to display file size information.

sizefmt determines the format to be used when displaying the size of a file. The available choices are bytes, for a formatted byte count (formatted as 1,234,567), or abbrev for an abbreviated version displaying the number of kilobytes or megabytes the file occupies.

e.g.
*!--#config sizefmt="abbrev"--* or
*!--#config sizefmt="bytes"--*

Use *!--#echo var="LAST_MODIFIED"--* for the date modified element.

See http://www.irt.org/...cles/js166/index.htm for more info.

* = Angle brackets <>.

Martin Webster
--
Cebidae's UK Internet Resource
http://www.cebidae.co.uk/
Quote Reply
Re: page size In reply to
Thanks For your Help, But I dont Have ssi
How can I do this without ssi

Quote Reply
Re: page size In reply to
 

Quote Reply
Re: page size In reply to
Here is an extract from the Perl documentation on a function called stat.
Code:
stat FILEHANDLE
stat EXPR
stat Returns a 13-element list giving the status info for a file,
either the file opened via FILEHANDLE, or named by EXPR.
If EXPR is omitted, it stats `$_'. Returns a null list
if the stat fails. Typically used as follows:

($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);

Not all fields are supported on all filesystem types.
Here are the meaning of the fields:

0 dev device number of filesystem
1 ino inode number
2 mode file mode (type and permissions)
3 nlink number of (hard) links to the file
4 uid numeric user ID of file's owner
5 gid numeric group ID of file's owner
6 rdev the device identifier (special files only)
7 size total size of file, in bytes
8 atime last access time since the epoch
9 mtime last modify time since the epoch
10 ctime inode change time (NOT creation time!) since the epoch
11 blksize preferred block size for file system I/O
12 blocks actual number of blocks allocated

(The epoch was at 00:00 January 1, 1970 GMT.)

If stat is passed the special filehandle consisting of
an underline, no stat is done, but the current contents
of the stat structure from the last stat or filetest are
returned. Example:

if (-x $file && (($d) = stat(_)) && $d < 0) {
print "$file is executable NFS file\n";
}

(This works on machines only for which the device number
is negative under NFS.)

Because the mode contains both the file type and its
permissions, you should mask off the file type portion
and (s)printf using a `"%o"' if you want to see the real
permissions.

$mode = (stat($filename))[2];
printf "Permissions are o\n", $mode & 07777;

In scalar context, `stat()' returns a boolean value
indicating success or failure, and, if successful, sets
the information associated with the special filehandle
`_'.

The File::stat module provides a convenient, by-name
access mechanism:

use File::stat;
$sb = stat($filename);
printf "File is %s, size is %s, perm o, mtime %s\n",
$filename, $sb->size, $sb->mode & 07777,
scalar localtime $sb->mtime;
The o, that show above in a few lines is % 0 4 o , with the spaces removed.

Based on that, you should be able to get the file size in Kb by specifying something similar to:
Code:
$filesize = int(((stat(/path/to/filename))[7]) / 1024);
or
Code:
use File::stat;
$filename = stat(/path/to/filename);
$filesize = int(($filename->size)/1024);
Be sure to change /path/to/filename to the location of the file on your system. You may also need to put it inside quotes.

I hope this helps.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/
Quote Reply
Re: page size In reply to
Please tel me where can I put this code

Thanks for you.


$filesize = int(((stat(/path/to/filename))[7]) / 1024);
or


use File::stat; $filename = stat(/path/to/filename); $filesize = int(($filename->size)/1024);


Quote Reply
Re: page size In reply to
Make the code into a sub routine called size. Then, using a method similar to Bmxer's, add to site_html_templates.pl in the %globals declaration the following:

size => &size

Now <%size%> is available in any of your templates.

Martin Webster
--
Cebidae's UK Internet Resource
http://www.cebidae.co.uk/
Quote Reply
Re: page size In reply to
where is the Bmxer's method
or can you tel me how can I convert this tag to php then I
Think this ok.
*!--#config sizefmt="bytes"--*








Quote Reply
Re: page size In reply to
I was referring the the method previously suggested by Bmxer. However, all you need to do is implement what I suggested in my previous reply and the code submitted by Bobsie.

Have you written the subroutine yet? Once you've done that, add size to the global declaration. All the information you need has already been posted! Mad

BTW, Links 2.0 generates the modified date (this is the build date).

Martin Webster
--
Cebidae's UK Internet Resource
http://www.cebidae.co.uk/
Quote Reply
Re: page size In reply to
Now this is the thing, I get troubled how can I write
the subroutine
Please let me know.

Thanks


Quote Reply
Re: page size In reply to
I don't have time to write routines for others; if I did, I'd never get anything else done. Frown

Perhaps you should take the plunge and start learning Perl! Try this link for starters: http://cgi.resourceindex.com/...ation/CGI_Tutorials/ or http://www.cgi101.com/class/. Wink

Martin Webster
--
Cebidae's UK Internet Resource
http://www.cebidae.co.uk/
Quote Reply
Re: page size In reply to
Thanks For your Info Frown
And all the people who try to help me.



Quote Reply
Re: page size In reply to
Are you using templates or not? In order to tell you where the code goes, that information would be needed.

- Bobsie
bobsie@orphanage.com
http://goodstuff.orphanage.com/