@ForAlex123
Начинающий junior

Как удалить пустые строки созданные Smarty?

Below is the part of the code which creates pdf with customer information. It works, but if some value (for example parish or state) is empty, then it creates empty row in the document.

1) First example
{sle n=c p=receiver/contact}
{foreach from=$c item=i name=contacts}
{gv c=$i p=person/name}
{gv c=$i p=organization/name}
{gv c=$i p=address/street} {gv c=$i p=address/house_nr} {gv c=$i p=address/appartment_nr}
{gv c=$i p=address/zip_code} {gv c=$i p=address/city}
{gv c=$i p=address/parish}
{gv c=$i p=address/state}
{if !$smarty.foreach.contacts.last}{/if}
{/foreach}

2) Second example
{if xpc(“gv“,“occupation“)}{gv p=occupation}{else}{/if}

If occupation is empty in my DMS, then empty row will be created. If there is variable value is empty, then code should just skip that part and go further without creating empty spaces. Thanks for help!

gv (get value) This tag is used to display the contents of the fields.

Parameters: Name Description

p path. Specifies the location in the XML tree

c context. Specifies the context in which a value search is performed.

t type. Specifies the field type. If not set, it will be displayed exactly as it is in the input.

req Required. Specifies whether the corresponding variable is required. Default is "true"

empty If the value is empty or missing (in the latter case req = false), the value of this variable is returned. For example. {gv p = my value req = false empty = empty}.
  • Вопрос задан
  • 86 просмотров
Пригласить эксперта
Ответы на вопрос 1
@lubezniy
May you try to use something like:
{if isset($person.name)}here is your gv code{/if}
?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы