Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Validate an URL

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
Aapje99
Smarty n00b


Joined: 04 Mar 2022
Posts: 2

PostPosted: Fri Mar 04, 2022 3:16 pm    Post subject: Validate an URL Reply with quote

Hi,

Im trying to valide an url before executing a certain code.

Something like {if $url = valid}Linkisvalid{else}Linkisnotvalid{/if}


To give a bit more context: I load in a product url from a database field to make a product feed. But when a product is turned off, aka the link is dead, I want the code to skip that product.

Btw im new to all of this so ill be happy to add more info if it's not clear
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Mar 17, 2022 9:49 pm    Post subject: Reply with quote

Then don't load that product from database in the first place.
Back to top
View user's profile Send private message
Aapje99
Smarty n00b


Joined: 04 Mar 2022
Posts: 2

PostPosted: Tue Apr 05, 2022 7:21 am    Post subject: Reply with quote

Thanks for the response, but thats not an option Sad
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 322
Location: West Coast

PostPosted: Wed Apr 06, 2022 3:34 am    Post subject: Reply with quote

What would be your essential test?

For example, you say "the link is dead". Do you mean that the database did not give a URL for this product? That is, an empty response?

Then, {if $url}, being true, because an empty value for $url is false-like, should be all you need.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Apr 06, 2022 11:15 am    Post subject: Reply with quote

Aapje99 wrote:
Thanks for the response, but thats not an option Sad

That IS an option. Write your query to NOT load disabled products, and you won't have this issue in the first place.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP