문자열 자르기에 관하여 답변좀 부탁드립니다. 정보
문자열 자르기에 관하여 답변좀 부탁드립니다.본문
<td width='<?=$subject_len?>' height='20' align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>{$list[$all_cnt][subject]}</a></td>
위 부분에서 제목 글자 수를 원하는 글자만큼 자르고 싶을때 어떻게 해야 하나요!
답변좀 부탁드립니다.
댓글 전체

어떻게 자르시는지...
그누 오른쪽 최신글처럼 보이는거는
<nobr style='display:block; overflow:hidden; width:200;'><a href='{$list[$i][href]}'>{$list[$i][subject]}</a></nobr>
요런식입니다..
그누 오른쪽 최신글처럼 보이는거는
<nobr style='display:block; overflow:hidden; width:200;'><a href='{$list[$i][href]}'>{$list[$i][subject]}</a></nobr>
요런식입니다..

cut_str($list[$all_cnt][subject],10,"..")

function cut_str($str, $len, $suffix="…")
{
global $g4;
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
if (strtoupper($g4['charset']) == 'UTF-8')
$s = substr($s, 0, $len - ($cnt % 3));
else
$s = substr($s, 0, $len - ($cnt % 2));
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
{
global $g4;
$s = substr($str, 0, $len);
$cnt = 0;
for ($i=0; $i<strlen($s); $i++)
if (ord($s[$i]) > 127)
$cnt++;
if (strtoupper($g4['charset']) == 'UTF-8')
$s = substr($s, 0, $len - ($cnt % 3));
else
$s = substr($s, 0, $len - ($cnt % 2));
if (strlen($s) >= strlen($str))
$suffix = "";
return $s . $suffix;
}
연후아빠님과 지윤지영님께 먼저 감사드립니다.
저의 설명이 부족했나요!
다시 질문드립니다.
http://www.sir.co.kr/bbs/tb.php/g4_skin/19470
위 주소를 클릭해 보시면 갤러리 최근게시물입니다.
제목 글자 자르기가 잘 안먹히네요.
<?=latest("flair_gallery", "테이블명", 전체갯수, 가로폭, "세로폭, row" );?>
최근게시물 불러오는 방법으로는 안될것 같아서 latest.skin.php파일에서 제목 문자 자르기를
삽입하려고 합니다.
<td width='<?=$subject_len?>' height='20' align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>{$list[$all_cnt][subject]}</a></td>
이 부분에서 제목 문자자르기 하면 될것 같은데...
아니면 다른 부분을 수정해야 하나요
<?
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
list($height, $row_cnt) = explode(",", $options);
$all_cnt = 0;
?>
<!-- <?=$board[bo_subject]?> (<?=$board[bo_table]?>) 최신글 -->
<table width='100%' cellpadding='0' cellspacing='0' border='0' align='left'>
<tr><td align='center'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='left'>
<tr>
<td width='226'> <strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font color=#000000><?=$board[bo_subject]?></font></a></strong></td>
<td width='49'><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/more.gif' border=0></a></td>
</tr>
<tr>
<td colspan=2 height=2 bgcolor='#b5a789'></td>
</tr>
</table>
</td></tr>
<tr><td align='center'>
<table width='95%'>
<? for ($k=0; $k<$row_cnt; $k++ ) { ?>
<tr>
<?
for ($i=0; $i<count($list)/$row_cnt; $i++)
{
if ($i > 0)
echo '<td width=20> </td>';
$title = get_text($list[$all_cnt][wr_subject]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$all_cnt][file][0][file]);
if (!file_exists($img) || !$list[$all_cnt][file][0][file])
$img = "$latest_skin_path/img/no_image.gif";
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
echo <<<HEREDOC
<td width='<?=$subject_len?>' valign='top' align='center'>
<table width='<?=$subject_len?>' border='0' cellpadding='0' cellspacing='0' align='center'>
<tr>
<td width='<?=$subject_len?>' height='5' align='center'></td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='<?=$height?>' align='center'>
<div style='width:<?=$subject_len?>px;height:<?=$height?>px;border:1px solid #CCCCCC;padding:3px' align='center'>
<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'><img src='{$img}' width='$subject_len' height='$height' border='0' align='absmiddle' title='$title'></a>
</div>
</td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='5' align='center'></td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='20' align='center'><a href='{$list[$i][href]}'>{$list[$i][subject]}</a></td>
</tr>
</table>
</td>
HEREDOC;
$all_cnt++;
}
?>
</tr>
<? } ?>
<? if (count($list) == 0) { ?>
<tr><td colspan=2 align='center' height=25>게시물이 없습니다.</td></tr>
<? } ?>
</table>
</td></tr>
</table>
좋은 답변 부탁드립니다.
모두들 행복한 연말 되세요!!!
감사! 감사!
저의 설명이 부족했나요!
다시 질문드립니다.
http://www.sir.co.kr/bbs/tb.php/g4_skin/19470
위 주소를 클릭해 보시면 갤러리 최근게시물입니다.
제목 글자 자르기가 잘 안먹히네요.
<?=latest("flair_gallery", "테이블명", 전체갯수, 가로폭, "세로폭, row" );?>
최근게시물 불러오는 방법으로는 안될것 같아서 latest.skin.php파일에서 제목 문자 자르기를
삽입하려고 합니다.
<td width='<?=$subject_len?>' height='20' align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>{$list[$all_cnt][subject]}</a></td>
이 부분에서 제목 문자자르기 하면 될것 같은데...
아니면 다른 부분을 수정해야 하나요
<?
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
list($height, $row_cnt) = explode(",", $options);
$all_cnt = 0;
?>
<!-- <?=$board[bo_subject]?> (<?=$board[bo_table]?>) 최신글 -->
<table width='100%' cellpadding='0' cellspacing='0' border='0' align='left'>
<tr><td align='center'>
<table width='100%' border='0' cellspacing='0' cellpadding='0' align='left'>
<tr>
<td width='226'> <strong><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><font color=#000000><?=$board[bo_subject]?></font></a></strong></td>
<td width='49'><a href='<?=$g4[bbs_path]?>/board.php?bo_table=<?=$bo_table?>'><img src='<?=$latest_skin_path?>/img/more.gif' border=0></a></td>
</tr>
<tr>
<td colspan=2 height=2 bgcolor='#b5a789'></td>
</tr>
</table>
</td></tr>
<tr><td align='center'>
<table width='95%'>
<? for ($k=0; $k<$row_cnt; $k++ ) { ?>
<tr>
<?
for ($i=0; $i<count($list)/$row_cnt; $i++)
{
if ($i > 0)
echo '<td width=20> </td>';
$title = get_text($list[$all_cnt][wr_subject]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
$img = "$g4[path]/data/file/$bo_table/".urlencode($list[$all_cnt][file][0][file]);
if (!file_exists($img) || !$list[$all_cnt][file][0][file])
$img = "$latest_skin_path/img/no_image.gif";
$href = "$g4[bbs_path]/board.php?bo_table=$bo_table";
echo <<<HEREDOC
<td width='<?=$subject_len?>' valign='top' align='center'>
<table width='<?=$subject_len?>' border='0' cellpadding='0' cellspacing='0' align='center'>
<tr>
<td width='<?=$subject_len?>' height='5' align='center'></td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='<?=$height?>' align='center'>
<div style='width:<?=$subject_len?>px;height:<?=$height?>px;border:1px solid #CCCCCC;padding:3px' align='center'>
<a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'><img src='{$img}' width='$subject_len' height='$height' border='0' align='absmiddle' title='$title'></a>
</div>
</td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='5' align='center'></td>
</tr>
<tr>
<td width='<?=$subject_len?>' height='20' align='center'><a href='{$list[$i][href]}'>{$list[$i][subject]}</a></td>
</tr>
</table>
</td>
HEREDOC;
$all_cnt++;
}
?>
</tr>
<? } ?>
<? if (count($list) == 0) { ?>
<tr><td colspan=2 align='center' height=25>게시물이 없습니다.</td></tr>
<? } ?>
</table>
</td></tr>
</table>
좋은 답변 부탁드립니다.
모두들 행복한 연말 되세요!!!
감사! 감사!
g4/lib/latest.lib.php
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
g4/lib/common.lib.php
function get_list($write_row, $board, $skin_path, $subject_len=40)
if ($subject_len)
$list['subject'] = conv_subject($list['wr_subject'], $subject_len, "…");
g4/lib/common.lib.php
// 제목을 변환
function conv_subject($subject, $len, $suffix="")
{
return cut_str(get_text($subject), $len, $suffix);
}
결국 cut_str을 부르는데 이게 동작을 안 하는 건가요?
for ($i=0; $row = sql_fetch_array($result); $i++)
$list[$i] = get_list($row, $board, $latest_skin_path, $subject_len);
g4/lib/common.lib.php
function get_list($write_row, $board, $skin_path, $subject_len=40)
if ($subject_len)
$list['subject'] = conv_subject($list['wr_subject'], $subject_len, "…");
g4/lib/common.lib.php
// 제목을 변환
function conv_subject($subject, $len, $suffix="")
{
return cut_str(get_text($subject), $len, $suffix);
}
결국 cut_str을 부르는데 이게 동작을 안 하는 건가요?
rolo님 답변에 감사드립니다.
cut_str을 부르는데 동작을 안하는 것이 아니라 제가 잘 몰라서 적용을 못하고 있습니다.
제목 나오는 이부분에서 적용 시키는 방법좀 부탁드립니다.
<td width='<?=$subject_len?>' height='20' align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>{$list[$all_cnt][subject]}</a></td>
어떻게 고쳐야 적용가능 하나요!
cut_str($list[$all_cnt][subject],10,"..") 이부분을 어떻게 삽입해야 하나요!
답변좀 부탁드립니다.
행복한 오후 시간 되세요!!!
cut_str을 부르는데 동작을 안하는 것이 아니라 제가 잘 몰라서 적용을 못하고 있습니다.
제목 나오는 이부분에서 적용 시키는 방법좀 부탁드립니다.
<td width='<?=$subject_len?>' height='20' align='center'><a href='$g4[bbs_path]/board.php?bo_table=$bo_table&wr_id={$list[$all_cnt][wr_id]}'>{$list[$all_cnt][subject]}</a></td>
어떻게 고쳐야 적용가능 하나요!
cut_str($list[$all_cnt][subject],10,"..") 이부분을 어떻게 삽입해야 하나요!
답변좀 부탁드립니다.
행복한 오후 시간 되세요!!!
for ($i=0; $i<count($list)/$row_cnt; $i++)
{
if ($i > 0)
echo '<td width=20> </td>';
$list[$all_cnt][subject]= cut_str($list[$all_cnt][subject],10,"..") ;
$title = get_text($list[$all_cnt][wr_subject]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
...
..
.
{
if ($i > 0)
echo '<td width=20> </td>';
$list[$all_cnt][subject]= cut_str($list[$all_cnt][subject],10,"..") ;
$title = get_text($list[$all_cnt][wr_subject]);
$content = cut_str(get_text($list[$all_cnt][wr_content]), 80);
...
..
.
좋은 답변 주셔서 감사합니다.
rolo님 때문에 문제를 해결했습니다.
감사! 감사!!
rolo님 때문에 문제를 해결했습니다.
감사! 감사!!
latest.lib.php를 안 쓰는 경우인가 보네요. ^^