|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Aapje99 Smarty n00b
Joined: 04 Mar 2022 Posts: 2
|
Posted: Fri Mar 04, 2022 3:16 pm Post subject: Validate an URL |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Mar 17, 2022 9:49 pm Post subject: |
|
|
Then don't load that product from database in the first place. |
|
Back to top |
|
Aapje99 Smarty n00b
Joined: 04 Mar 2022 Posts: 2
|
Posted: Tue Apr 05, 2022 7:21 am Post subject: |
|
|
Thanks for the response, but thats not an option |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Wed Apr 06, 2022 3:34 am Post subject: |
|
|
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 |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Apr 06, 2022 11:15 am Post subject: |
|
|
Aapje99 wrote: | Thanks for the response, but thats not an option |
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 |
|
|
|
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
|