I’m using a simple relationship custom field that stores other weblog entry IDs. If the default none is selected, nothing is set in the database. It’s a blank field.
I then run the following if statement and query. Logic would say, if the custom field is blank, then don’t run the query at all. But because of the way EE parses, the Query is first.
This is causing problems when the custom field is not set. The MySql query is running, looking for entry_id = blank, and then the page breaks.
{if my_custom_field !=""}{exp:query sql="SELECT title AS qtitle, url_title AS qurl FROM exp_weblog_titles WHERE entry_id={my_custom_field}"}<a href="/linkto/{qurl}/">Visit {qtitle} Page</a>{/exp:query}{/if}So what’s the correct workaround here? Is there a way to force the page to run the MySql query after the EE if statements? Do I need to hack the plugin to use 0 for none so at least there is a number in the db?
EE 1.7.0