- Posts: 118
COMMUNITY FORUM
Extrafield link type default value
- Alan Sparkes
-
Topic Author
- Offline
- Premium Member
Less
More
14 years 2 months ago #94008
by Alan Sparkes
Extrafield link type default value was created by Alan Sparkes
DOes anyone know how to check for the value of an empty extrafield when the type is a link?
It seems to output : <a href="http://"></a>
when 'empty' but i cant seem to get a check for the presence of a link.
Dumping it out shows an empty string when the title is empty but its not really empty - it has a value of "<a href="http://"></a>" which for some reason I cant catch.
any ideas?
It seems to output : <a href="http://"></a>
when 'empty' but i cant seem to get a check for the presence of a link.
Dumping it out shows an empty string when the title is empty but its not really empty - it has a value of "<a href="http://"></a>" which for some reason I cant catch.
any ideas?
Please Log in or Create an account to join the conversation.
- william white
-
- Offline
- Platinum Member
Less
More
- Posts: 3722
14 years 2 months ago #94009
by william white
Replied by william white on topic Extrafield link type default value
the value in the jos_k2_items table field - extra_fields when entered and saved empty is:
[{"id":"2","value":["","http:\/\/","same"]}]
with a value it looks like
[{"id":"2","value":["xlinktext","http:\/\/test.com","same"]}]
I would test for \/\/" in the value string to test it ( \ / \ / " ) using stripos
[{"id":"2","value":["","http:\/\/","same"]}]
with a value it looks like
[{"id":"2","value":["xlinktext","http:\/\/test.com","same"]}]
I would test for \/\/" in the value string to test it ( \ / \ / " ) using stripos
Please Log in or Create an account to join the conversation.
- Terry Britton
-
- Offline
- Elite Member
Less
More
- Posts: 198
14 years 2 months ago #94010
by Terry Britton
Replied by Terry Britton on topic Extrafield link type default value
Use strip_tags before testing if the field is empty.
$field = strip_tags(get the field info here);
Then test if $field is empty.
$field = strip_tags(get the field info here);
Then test if $field is empty.
Please Log in or Create an account to join the conversation.
- Alan Sparkes
-
Topic Author
- Offline
- Premium Member
Less
More
- Posts: 118
14 years 2 months ago #94011
by Alan Sparkes
Replied by Alan Sparkes on topic Extrafield link type default value
Top tips guys thanks.
Its interesting that dump of variable only shows link text value and nothing else. Is this a php /json thing?
I like the strip_tags approach but saw it after I found a way. IN the end I checked for strlen > 23 becuase the default value has 23 characters when there is no link, even if php var_dump doesnt think so.
thanks alot for your replies
Its interesting that dump of variable only shows link text value and nothing else. Is this a php /json thing?
I like the strip_tags approach but saw it after I found a way. IN the end I checked for strlen > 23 becuase the default value has 23 characters when there is no link, even if php var_dump doesnt think so.
thanks alot for your replies
Please Log in or Create an account to join the conversation.