Jump to content

PS 1.7 afficher un texte uniquement si présence de champs image, dans la personnalisation


Recommended Posts

Bonjour,

Je cherche à afficher un petit texte sur les droits d'auteur lorsqu'un client télécharge une image dans la partie personnalisation d'un produit.

J'ai ajouté ce code dans mon product-customization.tpl, mais cela ne fonctionne que si le dernier champs personnalisé est un champs "image", si c'est un champs "texte", ma div "droit-auteur-b" ne s'affiche donc pas.

{if $field.type == 'image'}
<div class="droit-auteur-b">
<p>Vous reconnaissez que vous avez tous les droits légaux d’utiliser les images que vous téléchargez !</p>
</div>
{/if}

Code complet :

{block name='product_customization_form'}
                <form class="needs-validation" method="post" action="{$product.url}" enctype="multipart/form-data"
                      novalidate autocomplete="false">
                    {foreach from=$customizations.fields item="field"}
                        <div class="form-group">
						<label for="field-{$field.id_customization_field}"> {$field.label}{if $field.required}<small class="texte-requis"> ({l s='Requis' d='Shop.Forms.Labels'})</small>{/if} {if !$field.required}<small class="text-muted"> ({l s='Optional' d='Shop.Forms.Labels'})</small>{/if}</label>
                        {*<label for="field-{$field.id_customization_field}"> {$field.label}{if !$field.required}<small class="text-muted"> ({l s='Optional' d='Shop.Forms.Labels'})</small>{/if}</label>*}
                        {if $field.type == 'text'}
                            <textarea placeholder="{l s='Your message here' d='Shop.Forms.Help'}"
                                      class="product-message form-control"
                                      maxlength="250" {if $field.required} required {/if} name="{$field.input_name}"
                                      id="field-{$field.id_customization_field}"></textarea>
                            <div class="invalid-feedback js-invalid-feedback-browser"></div>

                            <small class="form-text text-muted">{l s='250 char. max' d='Shop.Forms.Help'}</small>
                            {if $field.text !== ''}
                                <ul class="coche-perso"><strong class="customization-message">{l s='Your customization:' d='Shop.Theme.Catalog'}
                                    <label>{$field.text}</label>
                                </strong></ul>
                            {/if}
                        {elseif $field.type == 'image'}
                            {if $field.is_customized}
                                <div class="my-2">
                                    <img src="{$field.image.small.url}" class="border">
                                    <a class="remove-image btn btn-sm btn-outline-danger"
                                       href="{$field.remove_image_url}"
                                       rel="nofollow">{l s='Remove Image' d='Shop.Theme.Actions'}</a>
                                </div>
                            {/if}
                            <div class="custom-file">
                                <input class="custom-file-input" {if $field.required} required {/if} type="file"
                                       name="{$field.input_name}" id="field-{$field.id_customization_field}">
                                <label class="custom-file-label"
                                       for="field-{$field.id_customization_field}" data-browse="{l s='Choose file' d='Shop.Theme.Actions'}">{l s='Choose file' d='Shop.Theme.Actions'}</label>
                                <div class="invalid-feedback js-invalid-feedback-browser"></div>
                            </div>						
                            <small class="form-text text-muted">{l s='.png .jpg .gif' d='Shop.Forms.Help'}</small>

                        {/if}
                        </div>
                    {/foreach}
                  
                  <!-- AJOUT DU CODE -->
					{if $field.type == 'image'}
						<div class="droit-auteur-b">
							<p>Vous reconnaissez que vous avez tous les droits légaux d’utiliser les images que vous téléchargez !</p>
						</div>
					{/if}
                    <!-- FIN AJOUT DU CODE -->
                  
                    <button class="btn btn-primary" type="submit" name="submitCustomizedData">{l s='Save Customization' d='Shop.Theme.Actions'}</button>
                </form>
            {/block}

 

Y a t-il un moyen d'afficher la phrase sur les droits d'auteurs si et uniquement si un champs personnalisé de type "image" est présent ?


Merci.

Link to comment
Share on other sites

			{block name='product_customization_form'}
                <form class="needs-validation" method="post" action="{$product.url}" enctype="multipart/form-data"
                      novalidate autocomplete="false">
                    {foreach from=$customizations.fields item="field"}
                        <div class="form-group">
						<label for="field-{$field.id_customization_field}"> {$field.label}{if $field.required}<small class="texte-requis"> ({l s='Requis' d='Shop.Forms.Labels'})</small>{/if} {if !$field.required}<small class="text-muted"> ({l s='Optional' d='Shop.Forms.Labels'})</small>{/if}</label>
                        {*<label for="field-{$field.id_customization_field}"> {$field.label}{if !$field.required}<small class="text-muted"> ({l s='Optional' d='Shop.Forms.Labels'})</small>{/if}</label>*}
                        {if $field.type == 'text'}
                            <textarea placeholder="{l s='Your message here' d='Shop.Forms.Help'}"
                                      class="product-message form-control"
                                      maxlength="250" {if $field.required} required {/if} name="{$field.input_name}"
                                      id="field-{$field.id_customization_field}"></textarea>
                            <div class="invalid-feedback js-invalid-feedback-browser"></div>

                            <small class="form-text text-muted">{l s='250 char. max' d='Shop.Forms.Help'}</small>
                            {if $field.text !== ''}
                                <ul class="coche-perso"><strong class="customization-message">{l s='Your customization:' d='Shop.Theme.Catalog'}
                                    <label>{$field.text}</label>
                                </strong></ul>
                            {/if}
                        {elseif $field.type == 'image'}
                          {assign var="hasImage" value=true}
                            {if $field.is_customized}
                                <div class="my-2">
                                    <img src="{$field.image.small.url}" class="border">
                                    <a class="remove-image btn btn-sm btn-outline-danger"
                                       href="{$field.remove_image_url}"
                                       rel="nofollow">{l s='Remove Image' d='Shop.Theme.Actions'}</a>
                                </div>
                            {/if}
                            <div class="custom-file">
                                <input class="custom-file-input" {if $field.required} required {/if} type="file"
                                       name="{$field.input_name}" id="field-{$field.id_customization_field}">
                                <label class="custom-file-label"
                                       for="field-{$field.id_customization_field}" data-browse="{l s='Choose file' d='Shop.Theme.Actions'}">{l s='Choose file' d='Shop.Theme.Actions'}</label>
                                <div class="invalid-feedback js-invalid-feedback-browser"></div>
                            </div>						
                            <small class="form-text text-muted">{l s='.png .jpg .gif' d='Shop.Forms.Help'}</small>

                        {/if}
                        </div>
                    {/foreach}
                  
                  <!-- AJOUT DU CODE -->
					{if isset($hasImage) && $hasImage}
						<div class="droit-auteur-b">
							<p>Vous reconnaissez que vous avez tous les droits légaux d’utiliser les images que vous téléchargez !</p>
						</div>
					{/if}
                    <!-- FIN AJOUT DU CODE -->
                  
                    <button class="btn btn-primary" type="submit" name="submitCustomizedData">{l s='Save Customization' d='Shop.Theme.Actions'}</button>
                </form>
            {/block}

Dans l'idée j'assigne une variable si le champ image existe et je la teste après.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...