
Este truco le permite agregar enlaces a las noticias siguientes y anteriores al ver las noticias completas dentro del CMS de DataLife Engine. Era necesario poner algo así en su sitio, pero no puede encontrarlo en Internet, aproveché este truco que:
- Muestra enlaces a las noticias siguientes y anteriores en la misma categoría que las noticias vistas.
- En ausencia de noticias, el enlace no se muestra.
- Los enlaces se muestran en relación con la fecha de las noticias vistas.
- Fácil instalación (1 minuto).
- Edición mínima del código del motor.
- Los enlaces se almacenan en caché, respectivamente, se reduce la carga en la base de datos.
Primera opción
En la mayoría de los sitios dedicados al motor DLE, este truco se ha subido durante mucho tiempo, pero decidí reescribirlo cambiando el número de solicitudes e hice algunos cambios:
- Número de consultas 1 (en las dos anteriores - abajo)
- Al instalar, no necesita hacer ningún cambio en el código del motor
- Conéctese a las noticias completas a través del {include file...}
- la selección no es por fecha, sino por identificación (siguiente anterior a la identificación de las noticias vistas = id)
- Este método lo he probado en este sitio (https://tutorialesenlinea.es/) y en los sitios que tengo y los cuales funciona con el CMS de DataLife Engine.
- Descargar el archivo.
- Abrir engine/modules/ y subirlo en dicha carpeta.
- Luego abrir fullstory.tpl de tu plantilla o template. Y colocar:
{include file="engine/modules/nextpreviewnews.php"}
Descargar archivoDescargar archivo con Font Awesome
Segunda opción
En el motor de archivos buscar /modules/show.full.php y encuentre:
if( $config['related_news'] AND $view_template != "print") {
oif( $config['related_news'] ) {
E insertar arriba:// Inicio: enlaces a noticias siguientes y anteriores
$backnext_allow = 1;
if( $backnext_allow ) {
if( !$config['allow_cache'] ) {
$config['allow_cache'] = 1;
$revert_cache = true;
} else
$revert_cache = false;
$back_link = dle_cache( "backlink", $row['id'] );
$next_link = dle_cache( "nextlink", $row['id'] );
// Noticias anteriores
if( $back_link === FALSE ) {
$backlink = $db->super_query( "SELECT id, title, category, alt_name FROM " . PREFIX . "_post WHERE id < {$row['id']} AND category = '{$row['category']}' AND approve = '1' ORDER BY id DESC LIMIT 0,1" );
if( $backlink ) {
$backlink['category'] = intval( $backlink['category'] );
if( strlen( $backlink['title'] ) > 70 ) $backlink['title'] = substr( $backlink['title'], 0, 70 ) . "...";
if( $config['allow_alt_url'] ) {
if( $backlink['category'] and $config['seo_type'] == 2 ) {
$back_link = $config['http_home_url'] . get_url( $backlink['category'] ) . "/" . $backlink['id'] . "-" . $backlink['alt_name'] . ".html";
} else {
$back_link = $config['http_home_url'] . $backlink['id'] . "-" . $backlink['alt_name'] . ".html";
}
} else {
$back_link = $config['http_home_url'] . "index.php?newsid=" . $backlink['id'];
}
} else {
$back_link = "";
}
if( $back_link ) {
$back_link = "<span>Anterior » <b><a href="" . $back_link . "">" . stripslashes( $backlink['title'] ) . "</a></b></span>";
}
$db->free();
create_cache( "backlink", $back_link, $row['id'] );
}
// Próximas noticias
if( $next_link === FALSE ) {
$nextlink = $db->super_query( "SELECT id, title, category, alt_name FROM " . PREFIX . "_post WHERE id > {$row['id']} AND category = '{$row['category']}' AND approve = '1' ORDER BY id ASC LIMIT 0,1" );
if ( $nextlink ) {
$nextlink['category'] = intval( $nextlink['category'] );
if( strlen( $nextlink['title'] ) > 70 ) $nextlink['title'] = substr( $nextlink['title'], 0, 70 ) . "...";
if( $config['allow_alt_url'] ) {
if( $nextlink['category'] and $config['seo_type'] == 2 ) {
$next_link = $config['http_home_url'] . get_url( $nextlink['category'] ) . "/" . $nextlink['id'] . "-" . $nextlink['alt_name'] . ".html";
} else {
$next_link = $config['http_home_url'] . $nextlink['id'] . "-" . $nextlink['alt_name'] . ".html";
}
} else {
$next_link = $config['http_home_url'] . "index.php?newsid=" . $nextlink['id'];
}
} else {
$next_link = "";
}
if( $next_link ) {
$next_link = "<span style="float:right">« Далее <b><a href="" . $next_link . "">" . stripslashes( $nextlink['title'] ) . "</a></b></span>";
}
$db->free();
create_cache( "nextlink", $next_link, $row['id'] );
}
// Enlaces
$tpl->set( '{back-link}', $back_link );
$tpl->set( '{next-link}', $next_link );
if( $revert_cache ) $config['allow_cache'] = 0;
}
// Fin: enlaces a noticias siguientes y anteriores
Encuentre el archivo fullstory.tpl en la carpeta de su plantilla dle, ábralo y después de la línea: {full-story} y pegar abajo{back-link}{next-link}
Tercera opción
En el motor de archivos buscar /engine/inc/options.php y encuentre:
showRow( $lang['opt_sys_wdq'], $lang['opt_sys_wdsd'], makeDropDown( array ("1" => $lang['opt_sys_yes'], "0" => $lang['opt_sys_no'] ), "save_con[allow_quick_wysiwyg]", "{$config['allow_quick_wysiwyg']}" ) );
E inserte a continuación:showRow( 'Показывать предыдущую и следующую новость?', 'Показывать предыдущую и следующую новость?', makeDropDown( array ("1" => "Да", "0" => "Нет" ), "save_con[backnext_allow]", "{$config['backnext_allow']}" ) );
En el motor de archivos buscar /modules/show.full.php y encuentre:if( $config['related_news'] AND $view_template != "print") {
oif( $config['related_news'] ) {
E insertar arriba:if( $config['backnext_allow'] == "1" ) {
if( $config['allow_cache'] != "yes" ) {
$config['allow_cache'] = "yes";
$revert_cache = true;
} else
$revert_cache = false;
$back_link = dle_cache( "backlink", $row['id'] );
$next_link = dle_cache( "nextlink", $row['id'] );
if( $back_link === FALSE ) {
// Back Link
$backlink = $db->super_query( "SELECT id, date, title, category, alt_name, flag FROM " . PREFIX . "_post WHERE date < FROM_UNIXTIME({$row['date']}) AND category = '{$row['category']}' AND approve = '1' ORDER BY date DESC LIMIT 0,1" );
if( $backlink ) {
$backlink['date'] = strtotime( $backlink['date'] );
$backlink['category'] = intval( $backlink['category'] );
if( strlen( $backlink['title'] ) > 75 ) $backlink['title'] = substr( $backlink['title'], 0, 75 ) . " ...";
if( $config['allow_alt_url'] == "yes" ) {
if( $backlink['flag'] and $config['seo_type'] ) {
if( $backlink['category'] and $config['seo_type'] == 2 ) {
$back_link = $config['http_home_url'] . get_url( $backlink['category'] ) . "/" . $backlink['id'] . "-" . $backlink['alt_name'] . ".html";
} else {
$back_link = $config['http_home_url'] . $backlink['id'] . "-" . $backlink['alt_name'] . ".html";
}
} else {
$back_link = $config['http_home_url'] . date( 'Y/m/d/', $backlink['date'] ) . $backlink['alt_name'] . ".html";
}
} else {
$back_link = $config['http_home_url'] . "index.php?newsid=" . $backlink['id'];
}
} else {
$back_link = "";
}
if( $back_link ) {
$back_link = "Предыдущая новость: <a href="" . $back_link . "">" . stripslashes( $backlink['title'] ) . "</a>";
}
$db->free();
create_cache( "backlink", $back_link, $row['id'] );
}
if( $next_link === FALSE ) {
// Next Link
$nextlink = $db->super_query( "SELECT id, date, title, category, alt_name, flag FROM " . PREFIX . "_post WHERE date > FROM_UNIXTIME({$row['date']}) AND category = '{$row['category']}' AND approve = '1' ORDER BY date ASC LIMIT 0,1" );
if ( $nextlink ) {
$nextlink['date'] = strtotime( $nextlink['date'] );
$nextlink['category'] = intval( $nextlink['category'] );
if( strlen( $nextlink['title'] ) > 75 ) $nextlink['title'] = substr( $nextlink['title'], 0, 75 ) . " ...";
if( $config['allow_alt_url'] == "yes" ) {
if( $nextlink['flag'] and $config['seo_type'] ) {
if( $nextlink['category'] and $config['seo_type'] == 2 ) {
$next_link = $config['http_home_url'] . get_url( $nextlink['category'] ) . "/" . $nextlink['id'] . "-" . $nextlink['alt_name'] . ".html";
} else {
$next_link = $config['http_home_url'] . $nextlink['id'] . "-" . $nextlink['alt_name'] . ".html";
}
} else {
$next_link = $config['http_home_url'] . date( 'Y/m/d/', $nextlink['date'] ) . $nextlink['alt_name'] . ".html";
}
} else {
$next_link = $config['http_home_url'] . "index.php?newsid=" . $nextlink['id'];
}
} else {
$next_link = "";
}
if( $next_link ) {
$next_link = "Следующая новость: <a href="" . $next_link . "">" . stripslashes( $nextlink['title'] ) . "</a>";
}
$db->free();
create_cache( "nextlink", $next_link, $row['id'] );
}
if( $revert_cache ) $config['allow_cache'] = "no";
} else $back_link = $next_link = '';
// Back and Next Link Template
$tpl->set( '{back-link}', $back_link );
$tpl->set( '{next-link}', $next_link );
En la plantilla fullstory.tpl, en el lugar donde desea mostrar los enlaces, inserte:{back-link} - noticias anteriores
{next-link} - noticias siguientes
Las dos ultimas opciones no las he probado....
Comentarios