Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Модули » Как сделать поддержку short limit=x в полной новости?

Как сделать поддержку short limit=x в полной новости?


     02.12.2016    Модули, Хаки    1179

вопрос
В полной новости поддерживается тег short story но вот свойство limit не поддерживается а я хотел вывести картинки с помощью {image-x}. Но получается дубликат картинок т.к. нет обрезания html форматирования. Как такое реализовать, спасибо за ответ.

Ответил: Kane


В файле: engine\modules\show.full.php
Найти:
$tpl->set( '{short-story}', $row['short_story'] );

Ниже вставить:
if ( preg_match( "#\\{short-story limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
				$count= intval($matches[1]);
				
				$row['short_story'] = preg_replace( "#<!--TBegin(.+?)<!--TEnd-->#is", "", $row['short_story'] );
				$row['short_story'] = preg_replace( "#<!--MBegin(.+?)<!--MEnd-->#is", "", $row['short_story'] );
				$row['short_story'] = preg_replace( "'\[attachment=(.*?)\]'si", "", $row['short_story'] );
				$row['short_story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "", $row['short_story'] );
				
				$row['short_story'] = str_replace( "</p><p>", " ", $row['short_story'] );
				$row['short_story'] = strip_tags( $row['short_story'], "<br>" );
				$row['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", str_replace( "\n", " ", str_replace( "\r", "", $row['short_story'] ) ) ) ));
	
				if( $count AND dle_strlen( $row['short_story'], $config['charset'] ) > $count ) {
						
					$row['short_story'] = dle_substr( $row['short_story'], 0, $count, $config['charset'] );
						
					if( ($temp_dmax = dle_strrpos( $row['short_story'], ' ', $config['charset'] )) ) $row['short_story'] = dle_substr( $row['short_story'], 0, $temp_dmax, $config['charset'] );
					
				}
	
				$tpl->set( $matches[0], $row['short_story'] );
	
			}


В файле fullstory.tpl использовать {short-story limit="XXX"} где XXX это необходимая длина краткой новости.

2 комментария

wcw2007
Юзер

wcw2007 - 3 декабря 2016 17:34 -

Спасибо

wcw2007
Юзер

wcw2007 - 3 декабря 2016 18:19 -

А как в этом коде отставить вывод видео?

Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх