I uploaded 1 file and name it "test-test-test-test-test.php". It create problem in my layout. my layout is mess up. so if i upload file name up to 10 char then its fine.
views:
134answers:
4
+1
A:
Rename it before uploading.
In PHP:
<?php
$filename = 'test-test-test-test-test.php';
rename($filename, substr($filename, 0, 10) . '.php'));
?>
fabrik
2010-09-22 10:53:53
its CCK file field in drupal.i cant do like this.bcoz when i click on node view it has to be full view but on home page display only its trimmed.
dayana
2010-09-22 11:25:36
Then second option is yours. Trim filename as i wrote. Note: you'll need to take care about paths.
fabrik
2010-09-22 11:36:21
i found the solution my self..
dayana
2010-10-04 10:48:22
A:
$filename = 'testtesttesttesttesttest.php';
$filename = basename($path, ".php");
$filename = substr($filename, 0, 10);
$filename .= '.php';
Alexander.Plutov
2010-09-22 10:55:45
its CCK file field in drupal.i cant do like this.bcoz when i click on node view it has to be full view but on home page display only its trimmed.
dayana
2010-09-22 11:25:14
+1
A:
Single line solution
<?
$filename="test.php";
$filename=str_pad(trim($filename), 10, "123456789", STR_PAD_LEFT);
echo $filename;
//12test.php
$filename="test.php";
$filename=str_pad(trim($filename), 14, "123456789", STR_PAD_LEFT);
echo $filename;
//123456test.php
?>
JapanPro
2010-09-22 11:23:07
A:
I found the solution. Its using jquery.
jQuery("div.files .view-content .views-field-field-file-file-fid .filefield-file a") .each(function(){ var file_text = jQuery(this).text(); if(file_text.length > 10){ file_sub_text = file_text.substring(0,10); jQuery(this).text(file_sub_text+ "..."); } });
dayana
2010-10-04 10:51:52