Phpost
COMPLEMENTOS Imagen de cabecera para comunidades - Versión para impresión

+- Phpost (https://phpost.es)
+-- Foro: Risus 1.3 (https://phpost.es/forum-6.html)
+--- Foro: Complementos (https://phpost.es/forum-7.html)
+---- Foro: Complementos Terminados (https://phpost.es/forum-8.html)
+---- Tema: COMPLEMENTOS Imagen de cabecera para comunidades (/thread-37.html)



Imagen de cabecera para comunidades - Chctrpgo - 01-25-2021

Hola a tod@s, he visto un mensaje de @moyo pidiendo este mod y aquí lo dejo, no tengo las comunidades instaladas en el el tema default y se lo he instalado rápido para verlo en la V6, vale para cualquier tema, lo que cambias es el diseño.

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


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

Buscar:

Código PHP:
} elseif($type == 3) {
 
$this->mod_history($comid5$comid);
 
$name 'cf_'.(int)$comid.'.jpg';
 
$root TS_FILES.'uploads/'.$name;
 if(
copy($file['tmp_name'],$root)) return '1: '.$tsCore->settings['url'].'/files/uploads/'.$name;
 else return 
'0: No se pudo subir la imagen';
 } 


Agregar en la misma linea después de la llave de cierre:

Código PHP:
elseif($type == 4) {
                
$this->mod_history($comid6$comid);
                
$name 'head_'.(int)$comid.'.jpg';
                
$root TS_FILES.'uploads/'.$name;
                if(
copy($file['tmp_name'],$root)) return '1: '.$tsCore->settings['url'].'/files/uploads/'.$name;
                else return 
'0: No se pudo subir la imagen';
            } 


Quedando así:

Código PHP:
} elseif($type == 3) {
 
$this->mod_history($comid5$comid);
 
$name 'cf_'.(int)$comid.'.jpg';
 
$root TS_FILES.'uploads/'.$name;
 if(
copy($file['tmp_name'],$root)) return '1: '.$tsCore->settings['url'].'/files/uploads/'.$name;
 else return 
'0: No se pudo subir la imagen';
 } elseif(
$type == 4) {
                
$this->mod_history($comid6$comid);
                
$name 'head_'.(int)$comid.'.jpg';
                
$root TS_FILES.'uploads/'.$name;
                if(
copy($file['tmp_name'],$root)) return '1: '.$tsCore->settings['url'].'/files/uploads/'.$name;
                else return 
'0: No se pudo subir la imagen';
            } 


En ajax.comunidades.php --> inc --> php --> ajax --> ajax.comunidades.php

Buscar:

Código PHP:
case 'comunidades-edit_fondo':
 
//<--
 
$result $tsCom->uploadImagen($_FILES['background'], $_GET['comid'], 3);
            echo 
$tsCore->setJSON($result);
 
//-->
 
break; 


Debajo agregar:

Código PHP:
case 'comunidades-edit_header':
            
//<--
                
$result $tsCom->uploadImagen($_FILES['header'], $_GET['comid'], 4);
                echo 
$tsCore->setJSON($result);
            
//-->
        
break; 


En comunidades.js --> themes --> default --> js --> comunidades.js

Buscar:

Código PHP:
votar_tema: function(voto) { 


Arriba agregar:

Código PHP:
subir_cabecera: function() {
        $(
'#loading').fadeIn(250);
        if ($(
'#head_input').val()) {
            if(
isImageFile($('#head_input').val())){
                $(
'#head_change').css({'opacity' 0.5});
                $.
ajaxFileUpload({
                    
urlglobal_data.url '/comunidades-edit_header.php?' cgget('comid'true),
                    
fileElementId'head_input',
                    
dataType'json',
                    
success: function(h){
                        if(
h.charAt(0) == 1) {
                            $(
'#head_change').css({'opacity' 1});
                            $(
'#head_change').attr({'src' h.substring(3) + '?' + new Date().getTime()});
                        } else {
                            
mydialog.alert('Error'h.substring(3));
                        }                
                        $(
'#loading').fadeOut(250);
                    }
                });
            } else 
mydialog.alert('Error''El archivo no es una imagen válida.');
        } else 
mydialog.alert('Error''No selecciono ningun archivo.');
    }, 


Buscar:

Código PHP:
if(global_com.comid!='') {
 $(
'body').css({'background-image' 'url("' global_data.url '/files/uploads/cf_' global_com.comid '.jpg")'});
 } 


Debajo agregar:

Código PHP:
if(global_com.comid!='') {
        $(
'.headercom').css({'background-image' 'url("' global_data.url '/files/uploads/head_' global_com.comid '.jpg")'});
    } 


En c.crear_right.tpl --> themes --> default --> templates --> comunidades --> crear --> c.crear_right.tpl

Buscar:

Código PHP:
<input type="hidden" id="comid" value="{$tsDato.c_id}/>
 <
div class="com_box_title clearfix"><h2>Imagen de la comunidad</h2></div


Debajo agregar:

Código PHP:
<div class="com_box_title clearfix"><h2>Cabecera de la comunidad</h2></div>
    <
div class="com_edit_imagen" align="center">
        <
img src="{$tsConfig.url}/files/uploads/head_{$tsDato.c_id}.jpg" id="head_change" height="180" width="100%" />
        <
input type="file" id="head_input" class="input_text" name="header" style="width: 100%;" onchange="com.subir_cabecera({$tsDato.c_id})" />
    </
div


En c.com_info.tpl --> themes --> default --> templates --> comunidades --> inicio --> c.com_info.tpl

Buscar:

Código PHP:
<div class="ver_com_info">
    <
div class="vci_left floatL"


Reemplazar por:

Código PHP:
<div class="ver_com_info headercom">
    <
div class="opacity">
    <
div class="vci_left floatL"


Buscar:

Código PHP:
<a href="#" onclick="$('.ver_com_info').toggle();return false;"><class="com_icon icon_less"></i></a>
    <
div class="clearfix"></div>
</
div


Reemplazar por:

Código PHP:
<a href="#" onclick="$('.ver_com_info').toggle();return false;"><class="com_icon icon_less"></i></a>
    <
div class="clearfix"></div>
    </
div>
</
div


En comunidades.css --> themes --> default --> css --> comunidades.css

Agregar:

Código PHP:
.ver_com_info{padding:0}
.
headercom{background-position:center center;background-size:cover;background-repeat:no-repeat}
.
opacity{padding:20px 8px;background-color:rgba(255,255,255,.6)} 



Creditos: Miguel92