¡Bienvenido! ¿Aún no estás registrado?, deberás registrarte antes de poder usar el Chat, Comentar y Descargar en el Foro. Usa un email válido para la activación.
Calificación:
  • 0 voto(s) - 0 Media
  • 1
  • 2
  • 3
  • 4
  • 5

PREGUNTA Noticia diferente por página
#2

0
Hola, esto es lo que haría.
1 - Ejecuto esta consulta, con esto guardaremos la/s pagina/s que deseamos, ejemplo: home (una pagina) otra forma home,portal (dos o más paginas) y si se deja vacio, será de manera global!
 
ALTER TABLE `w_noticias` ADD `not_pages` VARCHAR(32) NOT NULL DEFAULT '' AFTER `not_active`;


2 - En c.admin.php modificar las siguientes funciones
 
function getNoticia() {...}
function 
newNoticia() {...}
function 
editNoticia() {...} 

por estas funciones
 
     /*
     getNoticia()
     */
    function getNoticia() {
        global $tsCore;
        //
        $not_id $tsCore->setSecure($_GET['nid']);
        //
        $query db_exec([__FILE____LINE__], 'query''SELECT `not_id`, `not_body`, `not_date`, `not_active`, `not_pages` FROM w_noticias WHERE not_id = \''  (int)$not_id '\' LIMIT 1');
        $data db_exec('fetch_assoc'$query);
        //
        return $data;
    }
     /*
     newNoticia()
     */
    function newNoticia() {
        global $tsCore$tsUser;
        //
        $not_body $tsCore->setSecure($tsCore->parseBadWords(substr($_POST['not_body'], 0190)));
        $not_active = empty($_POST['not_active']) ? 1;
        $not_pages $tsCore->setSecure($_POST['not_pages']);
        if (!empty($not_body)) {
            if (db_exec([__FILE____LINE__], 'query''INSERT INTO `w_noticias` (`not_body`, `not_autor`, `not_date`, `not_active`, `not_pages`) VALUES (\'' $not_body '\', \'' $tsUser->uid '\', \'' time() . '\', \'' $not_active '\', \'' $not_pages '\')'))
                 return true;
        }
        //
        return false;
     }
     /*
     editNoticia()
     */
    function editNoticia() {
        global $tsCore$tsUser;
        //
        $not_id intval($_GET['nid']);
        $not_body $tsCore->setSecure($tsCore->parseBadWords(substr($_POST['not_body'], 0190)));
        $not_active = empty($_POST['not_active']) ? 1;
        $not_pages $tsCore->setSecure($_POST['not_pages']);
        //
        if (!empty($not_body)) {
            if (db_exec([__FILE____LINE__], 'query''UPDATE `w_noticias` SET `not_autor` = \'' $tsUser->uid '\', `not_body` = \'' $not_body '\', not_active = \'' $not_active '\', not_pages = \'' $not_pages '\' WHERE not_id = \'' . (int)$not_id '\'')) return true;
        }
    


3 - En c.core.php buscar
 
function getNews() {...} 

y reemplazar toda la función.
 
    public function getNews() {
        global $tsPage;
        $query result_array(db_exec([__FILE____LINE__], 'query'"SELECT not_body, not_pages FROM w_noticias WHERE not_active = 1 ORDER BY RAND() LIMIT 5"));
        $tsPage $tsPage ?? $GLOBALS['_GET']['do'];
        $data = [];
        foreach ($query as $nid => $new) {
            $pages array_map('trim'explode(','$new['not_pages']));
            if ((empty($new['not_pages']) OR $tsPage === $new['not_pages']) OR in_array($tsPage$pages)) {
                $data[]['not_body'] = $this->parseBBCode($new['not_body'], 'news');
            }
        }
        return $data;
    


4 - En themes/default/templates/admin_mods/m.admin_noticias.tpl buscar
 
            <dl>
                <dt><label for="ai_not_active">Activar noticia:</label><br /><span>Activar inmediatamente esta noticia en {$tsConfig.titulo}.</span></dt>

y arriba añadir
            <dl>
                <dt><label for="ai_pages">En pagina:</label><br /><span>Donde deseas que se muestre la noticia.</span></dt>
                <dd><input type="text" id="ai_pages" name="not_pages" placeholder="home,portal,perfil,etc" value="{$tsNew.not_pages}" /></dd>
            </dl>

Accede al servidor de Discord y descarga ZCode
Responder


Compartir en:

Mensajes en este tema
Noticia diferente por página - por moyo - 03-04-2025, 11:39 PM
RE: Noticia diferente por página - por Miguel92 - 03-05-2025, 03:44 AM
RE: Noticia diferente por página - por moyo - 03-05-2025, 04:13 AM

Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)