Jump to content
  • 0

php в таблице html


Pro100User
 Share

Question

Здраствуйте, у меня есть html таблица, в ней тег [xfvalue_opisanie] (дополгительное поле DLE)

Мне нужно ограничить количество символов в этом поле.

нашел php script

function getPrewText( $text, $maxwords = 60, $maxchar = 50 )
{
$text = strip_tags( $text );
$words = split( ' ', $text );
$text='';
foreach ($words as $word){ {
if (mb_strlen($text.' '.$word)<$maxchar)
{$text.=' '.$word; }
else
{$text.='...';break;};
}
return $text;

как и куда мне его нада вставлять? Помогите пожалуйста.

Edited by Pro100User
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

<?php
function getPrewText( $text, $maxwords = 60, $maxchar = 50 )
{
$text = strip_tags( $text );
$words = split( ' ', $text );
$text='';
foreach ($words as $word){ {
if (mb_strlen($text.' '.$word)<$maxchar)
{$text.=' '.$word; }
else
{$text.='...';break;};
}
return $text;
?>

Ставь это посреди тега <body> и </body> но ни в коем случае не в <head> </head>

Edited by SteeLZzZ
Link to comment
Share on other sites

  • 0

мне наверно надо было сказать, что таблица находится в shortstory.tpl

собственно вот она:


<div class="post">
<div class="post-title">[full-link] {title} [/full-link]
<div id="rating">{rating}</div>
</div>

<table class="kino-table">
<tr> <td rowspan="5">{short-story}</td> <td class="kino-table1" >Год:</td> <th class="kino-table2">{year}</th> </tr>
<tr> <td class="kino-table1">Страна:</td> <th class="kino-table2">{country}</th></tr>
<tr> <td class="kino-table1">Режиссер:</td> <th class="kino-table2">{directorall}</th></tr>
<tr> <td class="kino-table1">В ролях:</td> <th class="kino-table2">{actorall}</th></tr>
<tr> <td colspan="3" class="kino-table3" {text limit="20"}>[xfgiven_opisanie]<font color="505050">Описание:</font>       [xfvalue_opisanie] [/xfgiven_opisanie]</td> </tr>
</table>

<div class="post-data">
<div class="data">
<span class="cell">Просмотров: {views}</span>
<span class="cell">[com-link]Комментариев: {comments-num}[/com-link]</span>
<span class="cell-adm">[edit]Редактировать[/edit]</span>
<ul>
<li class="more">[full-link]Смотреть[/full-link]</li>
</ul>
</div>
</div>
</div>

Может есть какието другие способы орезать текст?

h_1330361231_7197355_9ed67bf714.png

Edited by Pro100User
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy