datsa Posted November 10, 2015 Share Posted November 10, 2015 (edited) Buenas, En mi tienda tengo una serie de productos que tienen unos archivos adjuntos (pdf) y quiero saber si es posible configurar la tienda de forma que cuando el cliente intente descargar dichos ficheros adjuntos la pagina le obligue a estar registrado. Es decir que aunque los vea no pueda descargarlos si no está registrado en la web. No sé si es posible y agradecería cualquier información al respecto. Muchas gracias. EDITADO: Lo marco como solucionado, si alguien tiene el mismo problema y no se soluciona con el código de este hilo, que me contacte para poder ayudarle. Muchísimas gracias a todos. Edited February 7, 2018 by datsa (see edit history) Link to comment Share on other sites More sharing options...
ericzon Posted November 10, 2015 Share Posted November 10, 2015 Sí que es posible, simplemente tienes que ir a tu plantilla y envolver la parte de código referente a la descarga del archivo en: {if $logged}.....{/if} Un saludo 1 Link to comment Share on other sites More sharing options...
datsa Posted November 10, 2015 Author Share Posted November 10, 2015 Muchas gracias!! me da un poco de vergüenza pero... sabes dónde puedo encontrar el código? Me imagino que será en productos.tpl o algo asi, pero no estoy nada seguro. Muchas gracias por todo Link to comment Share on other sites More sharing options...
ericzon Posted November 10, 2015 Share Posted November 10, 2015 Claro, en el product.tpl busca por <!--Download --> Donde pone: <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> Pon lo que te he comentado antes: <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> {if $logged} <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {/if} Un saludo 1 Link to comment Share on other sites More sharing options...
datsa Posted November 10, 2015 Author Share Posted November 10, 2015 Muchas gracias, En un rato cuando llegue a casa lo pruebo y te comento que tal. Muchas gracias de nuevo!!!! Link to comment Share on other sites More sharing options...
datsa Posted November 11, 2015 Author Share Posted November 11, 2015 Buenos días! He realizado el cambio en /html/themes/default-bootstrap/product.tp quedando asi: <!--Download --> <section class="page-product-box"> <h3 class="page-product-heading">{l s='Download'}</h3> {foreach from=$attachments item=attachment name=attachements} {if $smarty.foreach.attachements.iteration %3 == 1}<div class="row">{/if} <div class="col-lg-4"> <h4><a href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> {if $logged} <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {/if} <hr /> </div> {if $smarty.foreach.attachements.iteration %3 == 0 || $smarty.foreach.attachements.last}</div>{/if} {/foreach} </section> <!--end Download --> Pero aun así sigo pudiendo descargar los adjuntos sin estar logado. ¿Sabéis por que podría ser?? Quedo a la espera de vuestras indicaciones y muchas gracias de antemano! Link to comment Share on other sites More sharing options...
datsa Posted November 11, 2015 Author Share Posted November 11, 2015 Disculpas, rectifico el anterior mensaje. Me explico: Cuando hago click sobre el archivo a descargar (un pdf) se previsualiza en el navegador. Una vez que dicha previsualización está abierta no te da la opción de guardar una copia pero sí que se puede hacer click con el botón derecho y "Guardar Como". Lo que deseo es que pida el logueo para esa primera visualización. Desconozco si es posible y agradezco cualquier tipo de ayuda al respecto. Muchas gracias! Link to comment Share on other sites More sharing options...
ericzon Posted November 11, 2015 Share Posted November 11, 2015 Vale, perdona, te respondí casi de memoria, prueba a cambiar este trozo: <div class="col-lg-4"> <h4><a href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> {if $logged} <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {/if} <hr /> </div> por: <div class="col-lg-4"> {if $logged} <h4><a href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {else} <h4>{$attachment.name|escape:'html':'UTF-8'}</h4> <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> {/if} <hr /> </div> Con eso debería marchar. 1 Link to comment Share on other sites More sharing options...
ventura Posted November 11, 2015 Share Posted November 11, 2015 Para versiones recientes de Prestashop utiliza mejor la variable global $is_logged $logged is depreceated. Dejara de utilizarse en proximas versiones 1 Link to comment Share on other sites More sharing options...
datsa Posted November 12, 2015 Author Share Posted November 12, 2015 Muy buenas noches, He realizado el cambio dejando mi código asi: <!--Download --> <section class="page-product-box"> <h3 class="page-product-heading">{l s='Download'}</h3> {foreach from=$attachments item=attachment name=attachements} {if $smarty.foreach.attachements.iteration %3 == 1}<div class="row">{/if} <div class="col-lg-4"> {if $is_logged} <h4><a href ="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {/if} <hr /> </div> {if $smarty.foreach.attachements.iteration %3 == 0 || $smarty.foreach.attachements.last}</div>{/if} {/foreach} </section> <!--end Download --> De esta forma el botón de descargar desaparece si no estás logado, sin embargo el titulo de las categorias es un link al propio archivo adjunto. Me imagino que la línea a editar debe ser: <h4><a href ="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> Alguien podría echarme una mano??? Muchas gracias por adelantado. Link to comment Share on other sites More sharing options...
ericzon Posted November 14, 2015 Share Posted November 14, 2015 Hola datsa, Efectivamente, ahí es donde hay que hacer otra modificación. Sustituye ese trozo por este: {if $is_logged} <h4><a href ="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> {else} <h4>{$attachment.name|escape:'html':'UTF-8'}</h4> {/if} 1 Link to comment Share on other sites More sharing options...
datsa Posted November 16, 2015 Author Share Posted November 16, 2015 Buenos días, He realizado las modificaciones indicadas quedando mi código asi: <!--Download --> <section class="page-product-box"> <h3 class="page-product-heading">{l s='Download'}</h3> {foreach from=$attachments item=attachment name=attachements} {if $smarty.foreach.attachements.iteration %3 == 1}<div class="row">{/if} <div class="col-lg-4"> {if $is_logged} <h4><a href ="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> {else} <h4>{$attachment.name|escape:'html':'UTF-8'}</h4> {/if} <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {/if} <hr /> </div> {if $smarty.foreach.attachements.iteration %3 == 0 || $smarty.foreach.attachements.last}</div>{/if} {/foreach} </section> <!--end Download --> Pero el titulo sigue siendo un enlace aunque no estés logado. He estado probando algunas cosillas, pero no consigo "quitar" el enlace del titulo. Agradecería cualquier ayuda!!! Gracias!!! Link to comment Share on other sites More sharing options...
datsa Posted November 16, 2015 Author Share Posted November 16, 2015 Buenas, haciendo algunas pruebas tal y como comentaba en el mensaje anterior he conseguido que el titulo no sea un enlace y que el botón descargar solo aparezca si estás logado. Mi código quedó asi: <!--Download --> <section class="page-product-box"> <h3 class="page-product-heading">{l s='Download'}</h3> {foreach from=$attachments item=attachment name=attachements} {if $smarty.foreach.attachements.iteration %3 == 1}<div class="row">{/if} <div class="col-lg-4"> {if $is_logged} <h4><a href ="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}">{$attachment.name|escape:'html':'UTF-8'}</a></h4> <p class="text-muted">{$attachment.description|escape:'html':'UTF-8'}</p> <a class="btn btn-default btn-block" href="{$link->getPageLink('attachment', true, NULL, "id_attachment={$attachment.id_attachment}")|escape:'html':'UTF-8'}"> <i class="icon-download"></i> {l s="Download"} ({Tools::formatBytes($attachment.file_size, 2)}) </a> {else} <h4>{$attachment.name|escape:'html':'UTF-8'}</h4> {/if} <hr /> </div> {if $smarty.foreach.attachements.iteration %3 == 0 || $smarty.foreach.attachements.last}</div>{/if} {/foreach} </section> <!--end Download --> Ahora que ya tengo esta funcionalidad, me gustaría que cuando un cliente no esté logado y quiera descargar algo la página le "invite" a logarse. No sé si esto será posible y agradezco cualquier información o idea la respecto. Saludos. Link to comment Share on other sites More sharing options...
datsa Posted December 22, 2015 Author Share Posted December 22, 2015 Buenos días, Sigo sin conseguir que el enlace de descarga "Invite a los usuarios a logarse". Os rogaría que si esta funcionalidad no es posible me lo indiquéis para dar por solucionado el tema. Muchísimas gracias de antemano. Link to comment Share on other sites More sharing options...
Recommended Posts