How can I point directly in a template to a particular custom field?
If I put {% for field in custom_fields %}{{ field.text }}{% endfor %} in a part of the template I get all the custom fields. Let’s say that I have two custom fields. I need to have the first one in a part of the page and the other one in another. How can I do this?
I dont know much in HTML but i know where you position something affect it display. if a Table is started, you can enter a custom field in there to display among the items in that table. A code will end the table and maybe another table started. You can insert another custom field in there as well.
I found the soultion
{% for field in custom_fields %}{% if (field.label !=‘Header’) %}{% continue %}{% endif %}
{% if field.text != null %}{{field.text}}{% else %}{{ title }}{% endif %}
{% endfor %}
{% for field in custom_fields %}
{% if (field.label !='Header') %}{% continue %}{% endif}
{% if field.text != nil %}{{field.text}}{% else %}{{ title }}{% endif %}
{% endfor %}
I don’t know why is always showing me field.text and not title even if the field.text is empty,
{% for field in custom_fields %}{% if (field.label !=‘Header’) %}{% continue %}{% else %}{{field.text}}{% endif %}
{% endfor %} {{title | replace: “Invoice”, “”}}
So the final result is that, if it is an invoice then, if a custom field exist and it’s called “Header” it will show the new title in the head of the template.
In order to avoid to display again in the footer this custom field I made same changes:
{% for field in custom_fields %}
{% if (field.label !='Header') %}
<tr>
<td colspan="99">
<div style="font-weight: bold; padding-top: 20px">{{ field.label }}</div>
<div>{{ field.text | newline_to_br }}</div>
</td>
</tr>{% continue %}{% endif %}
{% endfor %}
IF SOMEONE KNOWS HOT TO MAKE THIS WORK (IT DOESN’T SHOW TITLE IF “ELSE”) PLEASE EXPLAIN HOW:
{% for field in custom_fields %}{% if (field.label !=‘Header’) %}{% continue %}{% endif %}
{% if field.text != null %}{{field.text}}{% else %}{{ title }}{% endif %}
{% endfor %}
If you can explain clearly what you are trying to achieve and where you are trying to achieve it with the help of some images then maybe i can help. your posts are too confusing.
Right now in “sales invoices” I have a custom field that is called “Header”.
In the template I want that, IF
(a) there is a custom field.label called “Header” (in the purchase invoices right now I don’t have it but who knows…) AND (b) the custom field.text is not empty THAN
it displays custom field.text ELSE
it displays {{ title }}
<td style="font-weight: bold; font-size: 32px">
{% if title == 'Invoice' %}{% for field in custom_fields %}{% if (field.label == 'Header') %}{% if (field.text !='') %}{{ title | replace: title, field.text }}{% endif %}{% endif %}{% endfor %}{% else %}{{ title }}{% endif %}
</td>
Scroll down and add the following just after {% for field in custom_fields %}
{% if (field.label == 'Header') %}{% continue %}{% endif %}