- Поисковые системы
- Практика оптимизации
- Трафик для сайтов
- Монетизация сайтов
- Сайтостроение
- Социальный Маркетинг
- Общение профессионалов
- Биржа и продажа
- Финансовые объявления
- Работа на постоянной основе
- Сайты - покупка, продажа
- Соцсети: страницы, группы, приложения
- Сайты без доменов
- Трафик, тизерная и баннерная реклама
- Продажа, оценка, регистрация доменов
- Ссылки - обмен, покупка, продажа
- Программы и скрипты
- Размещение статей
- Инфопродукты
- Прочие цифровые товары
- Работа и услуги для вебмастера
- Оптимизация, продвижение и аудит
- Ведение рекламных кампаний
- Услуги в области SMM
- Программирование
- Администрирование серверов и сайтов
- Прокси, ВПН, анонимайзеры, IP
- Платное обучение, вебинары
- Регистрация в каталогах
- Копирайтинг, переводы
- Дизайн
- Usability: консультации и аудит
- Изготовление сайтов
- Наполнение сайтов
- Прочие услуги
- Не про работу
Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий
Здравствуйте !
Проблема в том, что на сайте уже набито большое кол-во роликов и все постеры к фильмам находятся в дополнительном поле. При попытке прописать в topnews и relatednews стандартное [xfgiven_poster][xfvalue_poster][/xfgiven_poster] , чтобы вытащить картинку - теги просто выводятся как текст, а значит не обрабатываются фактически.
Может кто сможет помочь? Лазил по инету, но РАБОЧЕГО варианта для dle 9.4 не нашел...
<?php
if( ! defined( 'DATALIFEENGINE' ) ) {die( "Hacking attempt!" );}
$topnews = dle_cache( "topnews", $config['skin'] );
if( $topnews === false ) {
$this_month = date( 'Y-m-d H:i:s', $_TIME );
$db->query( "SELECT id, title, date, alt_name, xfields, category, flag FROM " . PREFIX . "_post WHERE approve='1' AND date >= '$this_month' - INTERVAL 1 MONTH AND date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10" );
while ( $row = $db->get_row() ) {
$row['date'] = strtotime( $row['date'] );
$row['category'] = intval( $row['category'] );
$xfieldsdata = xfieldsdataload( $row['xfields'] );
if( $config['allow_alt_url'] == "yes" ) {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
if( dle_strlen( $row['title'], $config['charset'] ) > 22 ) $title = dle_substr( $row['title'], 0, 22, $config['charset'] ) . " ...";
else $title = $row['title'];
$link = "<a href=\"" . $full_link . "\">" . stripslashes( $title ) . "</a>";
$topnews .= "<li>" . $link . "</br>".$xfieldsdata['poster']."</li>";
}
$db->free();
create_cache( "topnews", $topnews, $config['skin'] );
}
?>
Держите, отпостил весь topnews потому-что потом появится куча вопросов, просто скопируйте этот код в topnews.php
22 - длина в символах заголовка новости
Держите, отпостил весь topnews потому-что потом появится куча вопросов, просто скопируйте этот код в topnews.php
22 - длина в символах заголовка новости
не прет 🙅
не понял? что не прет? наркотики?
или про что вы?
не понял? что не прет? наркотики?
или про что вы?
Сорри ) Хотел сказать,что не работает вообще такой вариант topnews, модуль даже текст с названием не выводит ...
а какая версия движка?
а какая версия движка?
9.4 nulled
дайте свой свой topnews.php
Модуль выглядит вот так
<?php
/*
=====================================================
DataLife Engine - by SoftNews Media Group
-----------------------------------------------------
http://dle-news.ru/
-----------------------------------------------------
Copyright (c) 2004,2011 SoftNews Media Group
=====================================================
Данный код защищен авторскими правами
=====================================================
Файл: topnews.php
-----------------------------------------------------
Назначение: вывод рейтинговых статей
=====================================================
*/
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
$tpl->result['topnews'] = dle_cache( "topnews", $config['skin'], true );
if( $tpl->result['topnews'] === false ) {
$this_month = date( 'Y-m-d H:i:s', $_TIME );
$tpl->load_template( 'topnews.tpl' );
$db->query( "SELECT id, short_story, title, date, alt_name, category, flag FROM " . PREFIX . "_post WHERE approve=1 AND date >= '$this_month' - INTERVAL 1 MONTH AND date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10" );
while ( $row = $db->get_row() ) {
$row['date'] = strtotime( $row['date'] );
$row['category'] = intval( $row['category'] );
if( $config['allow_alt_url'] == "yes" ) {
if( $row['flag'] and $config['seo_type'] ) {
if( $row['category'] and $config['seo_type'] == 2 ) {
$full_link = $config['http_home_url'] . get_url( $row['category'] ) . "/" . $row['id'] . "-" . $row['alt_name'] . ".html";
} else {
$full_link = $config['http_home_url'] . $row['id'] . "-" . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . date( 'Y/m/d/', $row['date'] ) . $row['alt_name'] . ".html";
}
} else {
$full_link = $config['http_home_url'] . "index.php?newsid=" . $row['id'];
}
if( dle_strlen( $row['title'], $config['charset'] ) > 55 ) $title = dle_substr( $row['title'], 0, 55, $config['charset'] ) . " ...";
else $title = $row['title'];
$tpl->set( '{title}', htmlspecialchars( strip_tags( stripslashes( $title ) ) ) );
$tpl->set( '{link}', $full_link );
$row['short_story'] = stripslashes( $row['short_story'] );
if( $user_group[$member_id['user_group']]['allow_hide'] ) $row['short_story'] = str_ireplace( "[hide]", "", str_ireplace( "[/hide]", "", $row['short_story']) );
else $row['short_story'] = preg_replace ( "#\[hide\](.+?)\[/hide\]#ims", "<div class=\"quote\">" . $lang['news_regus'] . "</div>", $row['short_story'] );
if (stripos ( $tpl->copy_template, "{image-" ) !== false) {
$images = array();
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'], $media);
$data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
foreach($data as $url) {
$info = pathinfo($url);
if (isset($info['extension'])) {
$info['extension'] = strtolower($info['extension']);
if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
}
}
if ( count($images) ) {
$i=0;
foreach($images as $url) {
$i++;
$tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
}
}
$tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "", $tpl->copy_template );
}
if ( preg_match( "#\\{text limit=['\"](.+?)['\"]\\}#i", $tpl->copy_template, $matches ) ) {
$count= intval($matches[1]);
$row['short_story'] = strip_tags( $row['short_story'], "<br>" );
$row['short_story'] = trim(str_replace( "<br>", " ", str_replace( "<br />", " ", $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'] );
} else $tpl->set( '{text}', $row['short_story'] );
$tpl->compile( 'topnews' );
}
$tpl->clear();
$db->free();
create_cache( "topnews", $tpl->result['topnews'], $config['skin'], true );
}
?>
А сам файл вывода topnews.tpl :
<li>
<a href="{link}">
<img src="[xfgiven_poster][xfvalue_poster][/xfgiven_poster] " alt="{title}" />
<span style="float: left;">
<span class="t-title">{title}</span>
{text limit="180"}
</span>
</a>
</li>
Рабочий вариант для 9.4:
Строку:
$db->query( "SELECT id, short_story, title, date, alt_name, category, flag FROM " . PREFIX . "_post WHERE approve=1 AND date >= '$this_month' - INTERVAL 1 MONTH AND date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10" );
заменить на:
$db->query( "SELECT id, short_story, xfields, title, date, alt_name, category, flag FROM " . PREFIX . "_post WHERE approve=1 AND date >= '$this_month' - INTERVAL 1 MONTH AND date < '$this_month' ORDER BY rating DESC, comm_num DESC, news_read DESC, date DESC LIMIT 0,10" );
Далее найти:
if (stripos ( $tpl->copy_template, "{image-" ) !== false) {
и ниже добавить:
$xfieldsdata = xfieldsdataload( $row['xfields'] );
Потом найти строку:
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $row['short_story'], $media);
и заменить на:
preg_match_all('/(img|src)=("|\')[^"\'>]+/i', $xfieldsdata['fieldname'], $media);
где вместо fieldname подставить имя своего дополнительного поля. - ['poster']
Вывод картинки в topnews.tpl через стандартный <img src="{image-1}">
Если еще актуально, могу скинуть рабочий файл по почте.