Jump to content

[SOLUCIONADO]Descarga de adjuntos usuarios registrados


datsa

Recommended Posts

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 by datsa (see edit history)
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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

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

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.

  • Like 1
Link to comment
Share on other sites

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

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}
  • Like 1
Link to comment
Share on other sites

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

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

  • 1 month later...

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

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...