¡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

COMPLEMENTOS Cambiar Plantilla (Usuario) (Act 1.3)
#1

10
Mejor respuesta del mensaje Cambiar Plantilla (Usuario) (Act 1.3)DEMO
Debes agradecer para ver el contenido...

Captura gif
 
[img]Registrate o inicia tu sesión para ver este contenido[/img]


En header.php

Buscar:
 
// Configuraciones
$smarty->assign('tsConfig',$tsCore->settings); 


Debajo agregar:
 
// Configuraciones
$smarty->assign('tsThemes',$tsCore->getThemes()); 


En c.core.php --> inc --> class --> c.core.php

Buscar:
 
function __construct()
{
// CARGANDO CONFIGURACIONES
$this->settings $this->getSettings();
$this->settings['domain'] = str_replace('http://','',$this->settings['url']);
$this->settings['categorias'] = $this->getCategorias();
$this->settings['default'] = $this->settings['url'].'/themes/default';
$this->settings['tema'] = $this->getTema();
$this->settings['images'] = $this->settings['tema']['t_url'].'/images';
$this->settings['css'] = $this->settings['tema']['t_url'].'/css';
$this->settings['js'] = $this->settings['tema']['t_url'].'/js';
//
if($_GET['do'] == 'portal' || $_GET['do'] == 'posts'$this->settings['news'] = $this->getNews();
# Mensaje del instalador y pendientes de moderación #
$this->settings['install'] = $this->existinstall();
$this->settings['novemods'] = $this->getNovemods();



Reemplazar por:
 
function __construct()
{
// CARGANDO CONFIGURACIONES
$this->settings $this->getSettings();
$this->settings['domain'] = str_replace('http://','',$this->settings['url']);
$this->settings['categorias'] = $this->getCategorias();
$this->settings['default'] = $this->settings['url'].'/themes/default';
if(!isset(
$_COOKIE['tema']) || !file_exists(TS_ROOT.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.$_COOKIE['tema'])) {
$default db_exec('fetch_array'db_exec(array(__FILE____LINE__), 'query''SELECT * FROM w_temas WHERE tid = '.$this->settings['tema_id']));
$_COOKIE['tema'] = $default['t_path'];
}
$this->settings['tema']['t_path'] = $_COOKIE['tema'];
$this->settings['tema']['t_url'] = $this->settings['url'].'/themes/'.$this->settings['tema']['t_path'];
$this->settings['images'] = $this->settings['tema']['t_url'].'/images';
$this->settings['css'] = $this->settings['tema']['t_url'].'/css';
$this->settings['js'] = $this->settings['tema']['t_url'].'/js';
//
if($_GET['do'] == 'portal' || $_GET['do'] == 'posts'$this->settings['news'] = $this->getNews();
# Mensaje del instalador y pendientes de moderación #
$this->settings['install'] = $this->existinstall();
$this->settings['novemods'] = $this->getNovemods();



Buscar:
 
/*
getNews()
*/
function getNews()
{
//
$query db_exec(array(__FILE____LINE__), 'query''SELECT not_body FROM w_noticias WHERE not_active = \'1\' ORDER by RAND()');
while(
$row db_exec('fetch_assoc'$query)){
$row['not_body'] = $this->parseBBCode($row['not_body'],'news');
$data[] = $row;
}
//
return $data;



Debajo agregar:
 
/*
getThemes()
*/
function getThemes(){
$query db_exec(array(__FILE____LINE__), 'query''SELECT * FROM w_temas');
return 
result_array($query);



En c.smarty.php --> inc --> class --> c.smarty.php

Buscar:
 
function __construct()
{
global 
$tsCore;
//
$this->template_dir TS_ROOT.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.TS_TEMA.DIRECTORY_SEPARATOR.'templates';
$this->compile_dir TS_ROOT.DIRECTORY_SEPARATOR.'cache';
$this->template_cb = array('url' => $tsCore->settings['url'], 'title' => $tsCore->settings['titulo']);
//
$this->_tpl_hooks = array();



Reemplazar por:
 
function __construct()
{
global 
$tsCore;
//
$this->template_dir TS_ROOT.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.TS_TEMA.DIRECTORY_SEPARATOR.'templates';
$this->compile_dir TS_ROOT.DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR.TS_TEMA;
if(!
file_exists($this->compile_dir)) mkdir($this->compile_dir);
$this->template_cb = array('url' => $tsCore->settings['url'], 'title' => $tsCore->settings['titulo']);
//
$this->_tpl_hooks = array();




Importante: Ahora este código debe estar en todas la plantillas, si no, solo se podría cambiar el theme desde una plantilla y desde las otras no.

Ejemplo en el footer

Buscar:
 
<a href="{$tsConfig.url}/pages/dmca/">Report Abuse DMCA</a


Debajo agregar:
 
<class="blanco" onclick="change.menu();">Cambiar plantilla</a>
<
style>
{
literal}
.
change_option displayblockpadding10px 15pxborder-bottom1px solid #ccc; }
.change_option:first-child border-top1px solid #ccc; }
.change_option:hover background#444; color: white; }
{/literal}
</
style>
<
script>
{
literal}
var 
change = {
menu: function() {
mydialog.show();
mydialog.title('Cambiar plantilla');
mydialog.body('{/literal}{foreach from=$tsThemes item=t}<a class="change_option" onclick="change.theme({$t.tid})">{if $tsConfig.tema.t_path == $t.t_path}<img src="{$tsConfig.images}/tick-button.png" style="vertical-align: middle;">{/if} {$t.t_name}</a>{/foreach}{literal}');
mydialog.buttons(truetrue'Cancelar''close'true);
mydialog.center();
},
theme: function(id) {
$.
get(global_data.url+'/change.php?theme='+id).done(function() { window.location.reload(); });
}
};
{/
literal}
</
script


Y subir esta carpeta


Mega
Debes agradecer para ver el contenido...

Google Drive
Debes agradecer para ver el contenido...

Mediafire
Debes agradecer para ver el contenido...



Creditos: Debes agradecer para ver el contenido...
Responder
#2

0
en c.smarty.php, lo mas parecido que tengo es esto:
 
function tsSmarty() {
    global $tsCore;
    # necesario para que smarty pueda imprimir la plantilla
    parent::__construct();
    //
    # setea los directorios para smarty
    $this->setTemplateDir(TS_ROOT . DIRECTORY_SEPARATOR .'themes'. DIRECTORY_SEPARATOR . TS_TEMA . DIRECTORY_SEPARATOR . 'templates');
    $this->setCompileDir(TS_ROOT . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'templates_c');
    $this->setCacheDir(TS_ROOT . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'cache');
        $this->setConfigDir(array(
      'url' => $tsCore->settings['url'],
      'title' => $tsCore->settings['titulo'])
    );
    # define si smarty esta en modo depuracion
    $this->debugging = false;
    # define la configuracion de cache
    $this->caching = false;
    # define tiempo de vida de cache, si esta activa
    $this->cache_lifetime = 10;
    # no se que es xd
    $this->_tpl_hooks = array();
  }

no puedo continuar desde ese punto editando
Responder
#3

1
Hola @vaniglia , cambialo por esto
function tsSmarty() {
    global 
$tsCore;
    
# necesario para que smarty pueda imprimir la plantilla
    
parent::__construct();
    
//
    # setea los directorios para smarty 
    
$this->setTemplateDir(TS_ROOT DIRECTORY_SEPARATOR .'themes'DIRECTORY_SEPARATOR TS_TEMA DIRECTORY_SEPARATOR 'templates');
    
$this->setCompileDir(TS_ROOT DIRECTORY_SEPARATOR 'cache' DIRECTORY_SEPARATOR.TS_TEMA 'templates_c');
    
$this->setCacheDir(TS_ROOT DIRECTORY_SEPARATOR 'cache' DIRECTORY_SEPARATOR 'cache');
        
$this->setConfigDir(array(
      
'url' => $tsCore->settings['url'],
      
'title' => $tsCore->settings['titulo'])
    ); 
Responder
#4

1
(03-23-2021, 08:18 AM)Tronlar escribió: Debes agradecer para ver el contenido...Hola @vaniglia , cambialo por esto
function tsSmarty() {
    global 
$tsCore;
    
# necesario para que smarty pueda imprimir la plantilla
    
parent::__construct();
    
//
    # setea los directorios para smarty 
    
$this->setTemplateDir(TS_ROOT DIRECTORY_SEPARATOR .'themes'DIRECTORY_SEPARATOR TS_TEMA DIRECTORY_SEPARATOR 'templates');
    
$this->setCompileDir(TS_ROOT DIRECTORY_SEPARATOR 'cache' DIRECTORY_SEPARATOR.TS_TEMA 'templates_c');
    
$this->setCacheDir(TS_ROOT DIRECTORY_SEPARATOR 'cache' DIRECTORY_SEPARATOR 'cache');
        
$this->setConfigDir(array(
      
'url' => $tsCore->settings['url'],
      
'title' => $tsCore->settings['titulo'])
    ); 

muchas gracias, ahora pruebo Smile

funciona muy bien!

por si sirve de aporte, el archivo footer está en 
themes/<nombre del tema>/templates/sections/main_footer.tpl

por ejemplo:

themes/default/templates/sections/main_footer.tpl
y
/Flatpost/templates/sections/main_footer.tpl
Responder
#5

1
Gracias
Responder


Compartir en:

Salto de foro:


Usuarios navegando en este tema: 1 invitado(s)