giorgino Well-known member Dec 29, 2021 #1 Hi all, I need to insert an ad below the messages that are longer than x chars. Is it possibile to achieve this with xenforo conditionals? Thanks
Hi all, I need to insert an ad below the messages that are longer than x chars. Is it possibile to achieve this with xenforo conditionals? Thanks
Solution P P Paul B Dec 29, 2021 My fault. Code: <xf:if is="{{strlen($post.message) > 100}}"> You need to use double braces for functions.
My fault. Code: <xf:if is="{{strlen($post.message) > 100}}"> You need to use double braces for functions.
P Paul B XenForo moderator Staff member Dec 29, 2021 #2 Untested but you can probably use something like: <xf:if is="strlen($post.message) > 100"> Upvote 0 Downvote
giorgino Well-known member Dec 29, 2021 #3 Brogan said: Untested but you can probably use something like: <xf:if is="strlen($post.message) > 100"> Click to expand... The ad is shown in the small posts too. It seems that the condition > 100 doesn't works Upvote 0 Downvote
Brogan said: Untested but you can probably use something like: <xf:if is="strlen($post.message) > 100"> Click to expand... The ad is shown in the small posts too. It seems that the condition > 100 doesn't works
P Paul B XenForo moderator Staff member Dec 29, 2021 #4 Did you check that the var is correct -- $post.message ? You will need to dump the vars for the template you are using to confirm what it is. Identifying and using variables in templates, advertising positions, navigation entries, and widgets What are variables? In simple terms, variables are names which hold values. These values are stored in the database and are used in templates to evaluate and present the content and data. Using variables in templates opens up a lot of... xenforo.com Upvote 0 Downvote
Did you check that the var is correct -- $post.message ? You will need to dump the vars for the template you are using to confirm what it is. Identifying and using variables in templates, advertising positions, navigation entries, and widgets What are variables? In simple terms, variables are names which hold values. These values are stored in the database and are used in templates to evaluate and present the content and data. Using variables in templates opens up a lot of... xenforo.com
giorgino Well-known member Dec 29, 2021 #5 Yeah the var $post.message exist The template is thread_view and I'm using the ad position "below message content" Upvote 0 Downvote
Yeah the var $post.message exist The template is thread_view and I'm using the ad position "below message content"
P Paul B XenForo moderator Staff member Dec 29, 2021 #6 My fault. Code: <xf:if is="{{strlen($post.message) > 100}}"> You need to use double braces for functions. Upvote 0 Downvote Solution
My fault. Code: <xf:if is="{{strlen($post.message) > 100}}"> You need to use double braces for functions.
giorgino Well-known member Dec 29, 2021 #7 Brogan said: My fault. Code: <xf:if is="{{strlen($post.message) > 100}}"> You need to use double braces for functions. Click to expand... Same issue The ad is shown in every message Upvote 0 Downvote
Brogan said: My fault. Code: <xf:if is="{{strlen($post.message) > 100}}"> You need to use double braces for functions. Click to expand... Same issue The ad is shown in every message
P Paul B XenForo moderator Staff member Dec 29, 2021 #8 I tested it on my local and it works as expected. Upvote 0 Downvote
giorgino Well-known member Dec 29, 2021 #9 giorgino said: Same issue The ad is shown in every message Click to expand... Now I've edited the lenght from 100 to 500 and seems to work. But the number of chars aren't 500. Weird... Upvote 0 Downvote
giorgino said: Same issue The ad is shown in every message Click to expand... Now I've edited the lenght from 100 to 500 and seems to work. But the number of chars aren't 500. Weird...
P Paul B XenForo moderator Staff member Dec 29, 2021 #10 Spaces are counted. So 'short post' would be 10 and 'test test test test' would be 19. Upvote 0 Downvote
giorgino Well-known member Dec 29, 2021 #11 Brogan said: I tested it on my local and it works as expected. Click to expand... Thank you Bro(gan) your help is amazing Upvote 1 Downvote
Brogan said: I tested it on my local and it works as expected. Click to expand... Thank you Bro(gan) your help is amazing