HTML Content in Custom Fields

Discussion in 'General discussions' started by chris.p, Aug 22, 2019.

  1. chris.p

    chris.p New Member

    Joined:
    Sep 11, 2018
    Messages:
    8
    Likes Received:
    0
    S.E:
    2020-02-21 18:42:57
    L.T:
    Regular
    L.C:
    1
    Hello!

    I thought I had read somewhere that html content was supported in custom fields. Is that not the case? Whether I run an import or try to manually save the field, the html tags get stripped out.

    The field is used to build out a table of varying size, so it would be a pain to try and build into the template itself.

    Perhaps I'm missing something obvious? Any help would be much appreciated.

    Thanks!
     
  2. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,445
    Likes Received:
    2,430
    @chris.p - custom fields are limited to 255 bytes in length, so this means roughly 255 characters at most, which makes them not suitable for storing html. This is also the reason it gets stripped.
    I am sure there are other ways to accomplish what you're after. I assume you need big blobs of html injected in various parts of your template? There is a tag called [REMOTE_CONTENT] which can be used to fetch content from a url, so you could potentially load your html content from remote location. The content is cached and reused, so you won't get any performance issues.
    Code:
    [REMOTE_CONTENT url='https://www.domain.com/some-html-framgment.html']
    
     
  3. chris.p

    chris.p New Member

    Joined:
    Sep 11, 2018
    Messages:
    8
    Likes Received:
    0
    S.E:
    2020-02-21 18:42:57
    L.T:
    Regular
    L.C:
    1
    Ah, ok, that makes sense.

    The html content is unique to each subscriber. It's not huge by any means, but it is over 255 char. In that remote_content tag, can I make that url dynamic? Maybe using a custom field in it? Are there other options?
     
  4. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,445
    Likes Received:
    2,430
    TBH i don't know if custom fields will work in that custom field, you'll have to try and see.
    Other than this, i assume it should be some custom work around the tags parsing, or maybe enable twig and extend it to match your use case.
     
  5. Nick Thacke

    Nick Thacke New Member

    Joined:
    Aug 29, 2019
    Messages:
    26
    Likes Received:
    5
    S.E:
    2020-02-27 13:39:18
    L.T:
    Regular
    L.C:
    1
    How do we change the url inside the [REMOTE_CONTENT=url:....] tag?
     
    nadworks likes this.
  6. nadworks

    nadworks Member

    Joined:
    Apr 20, 2015
    Messages:
    123
    Likes Received:
    15
    S.E:
    2019-12-16 02:05:25
    L.T:
    Regular
    L.C:
    2
    I have a similar question:
    For a custom field that either has value A or value B within a list, I'd like to show REMOTE FILE A.htm or B.htm.
    How can I achieve that?
     
    chris.p likes this.
  7. chris.p

    chris.p New Member

    Joined:
    Sep 11, 2018
    Messages:
    8
    Likes Received:
    0
    S.E:
    2020-02-21 18:42:57
    L.T:
    Regular
    L.C:
    1
    I tried to do this several ways, but wasn't able to make it work. Nesting custom fields didn't work for me. Though I was having problems getting remote content to load correctly at all.

    My case was pretty time-sensitive, so I had to find an alternative solution, but if you find something that works, please update this thread - it would be great to know.
     
  8. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,445
    Likes Received:
    2,430
    With custom coding only. I don't see how mailwizz would be able to understand that you'd like to load a remote file, unless we design a custom field for this purpose, but if we do, how would that work?
     
  9. nadworks

    nadworks Member

    Joined:
    Apr 20, 2015
    Messages:
    123
    Likes Received:
    15
    S.E:
    2019-12-16 02:05:25
    L.T:
    Regular
    L.C:
    2
    Maybe I'm misunderstanding the [REMOTE_CONTENT=url:....] tag you mentioned earlier. But that's what I'm ref. to.
    I'd hoped there could be some sort of a {% if ... %}... {% else %} solution.

    Something like...

    {% if TYPE == 'artist' %}
    [REMOTE_CONTENT=url:https://mydomain.com/A.htm]
    {% elseif TYPE == 'promoter' %}
    [REMOTE_CONTENT=url:https://mydomain.com/B.htm]
    {% endif %}
     
    Last edited: Nov 8, 2019
  10. gteindia

    gteindia New Member

    Joined:
    Apr 28, 2018
    Messages:
    26
    Likes Received:
    1
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    This would be interesting. I could pick up values from the database depending on the User ID selected. There are so many possibilities.
     
  11. chris.p

    chris.p New Member

    Joined:
    Sep 11, 2018
    Messages:
    8
    Likes Received:
    0
    S.E:
    2020-02-21 18:42:57
    L.T:
    Regular
    L.C:
    1
    Also maybe consider the ability to dynamically populate that remote_content url tag with a custom field. Then you could pass that info as a url parameter and have an external script generate html content depending on it's value. I'm not sure how that would work with the caching you referenced earlier, but it's a thought.
     
  12. gteindia

    gteindia New Member

    Joined:
    Apr 28, 2018
    Messages:
    26
    Likes Received:
    1
    S.E:
    Expired
    L.T:
    Regular
    L.C:
    1
    Again only an idea: How would it be if the Remote Content tag could have two variants - one with caching and no input parameters and the second without caching and with input parameters.
     
  13. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,445
    Likes Received:
    2,430
    You can already do this, just enable twig template engine and that's it, you should be able to do the rest just fine.

    Code:
    {% if TYPE == 'artist' %}
    [REMOTE_CONTENT url='https://mydomain.com/A.htm']
    {% elseif TYPE == 'promoter' %}
    [REMOTE_CONTENT url='https://mydomain.com/B.htm']
    {% endif %}
    
    Did you try it ?
     
  14. nadworks

    nadworks Member

    Joined:
    Apr 20, 2015
    Messages:
    123
    Likes Received:
    15
    S.E:
    2019-12-16 02:05:25
    L.T:
    Regular
    L.C:
    2
    I have not yet been able to get external content to work at all - even outside of this statement.
    Is there another plugin I'd need to activate or anything else I might have missed?
     
  15. ghimes

    ghimes New Member Staff Member Support Staff

    Joined:
    Feb 2, 2018
    Messages:
    23
    Likes Received:
    9
    Hello,
    You have to enable the template engine first from Backend->Settings->Campaigns->Template-engine
    Cosmin
     
    nadworks likes this.
  16. nadworks

    nadworks Member

    Joined:
    Apr 20, 2015
    Messages:
    123
    Likes Received:
    15
    S.E:
    2019-12-16 02:05:25
    L.T:
    Regular
    L.C:
    2
    Was already enabled.
     
  17. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,445
    Likes Received:
    2,430
    The only reason i can think of for this is that your hosting blocks outgoing connections, but i assume that's not true, right?
    Can you give us the real url to such file so we can test it in our dev ?
     
  18. nadworks

    nadworks Member

    Joined:
    Apr 20, 2015
    Messages:
    123
    Likes Received:
    15
    S.E:
    2019-12-16 02:05:25
    L.T:
    Regular
    L.C:
    2
  19. twisted1919

    twisted1919 Administrator Staff Member

    Joined:
    Dec 27, 2014
    Messages:
    10,445
    Likes Received:
    2,430
    Here's how the tag looks in code:
    Screenshot 2019-11-12 11.42.29.png
    And in the template:
    Screenshot 2019-11-12 11.43.09.png

    And the result:
    Screenshot 2019-11-12 11.45.12.png

    So it def. works, just make sure in source mode, your tag does not contain garbage html which could prevent it being parsed properly by mailwizz.
     
    nadworks likes this.
  20. nadworks

    nadworks Member

    Joined:
    Apr 20, 2015
    Messages:
    123
    Likes Received:
    15
    S.E:
    2019-12-16 02:05:25
    L.T:
    Regular
    L.C:
    2
    Fab. Thanks so much - I'll give it another shot.
     

Share This Page