Fixed the request when exclude_template is set in Attribute and Feature loops

If no specific template is set, we cannot use the position from the attribute_template (or feature_template), as the left join may return several attribute (or feature) occurences.