Hey Jack, welcome to the forums!
I saw that you reached out directly earlier today and only just saw your post here, so I thought I’d re-post my response here so that it’s public in case anyone else is asking themselves a similar question.
For starters, it’s important to recognize that PHP variables and L&L variables are not the same thing and can’t natively communicate with each other as you’ve tried to do in the L&L markup you shared. When you declare a variable in your myfunctions.php file, that variable isn’t only accessible within that PHP file unless you do something with it (within your myfunctions.php file) to make it accessible elsewhere. For example, you could theoretically save that variable as a field on the current user’s profile, at which point it would be in the database and L&L would be able to read that user field from your site’s database. Since it sounds like you’re instead trying to create some kind of conditional logic that works even when a user isn’t logged in, the simplest way to do this would probably be to create a shortcode that you could reference throughout your site (including being able to reference it in your L&L code). Here’s an article to get you started with creating a shortcode if you’re not familiar with that.
Once your shortcode has been created, you can then reference the shortcode in your L&L template. Since you’re trying to reference the country code as an attribute value, you’ll probably want to start by using your shortcode to define an L&L variable (again, that’s a different kind of variable than the PHP variable you created earlier) and then use the Get
tag to reference the variable in the value of an attribute. So in practice, that could look something like this, depending on how you choose to set up your shortcode and what the rest of your L&L template is supposed to do:
<Set my_loopsandlogic_country_variable>
<Shortcode my_country_shortcode_name />
</Set>
<If field=countries value="{Get my_loopsandlogic_country_variable}">
This text will be displayed when the my_loopsandlogic_country_variable L&L variable matches whatever is contained in the "countries" field for the current page or current loop.
</If>
It might also work to use the Shortcode tag directly inside the value
attribute like this:
<If field=countries value="{Shortcode my_country_shortcode_name}">
Content to be displayed goes here.
</If>
Although I haven’t played around with that syntax to know if that would work as expected. Worth a try though once you’ve created your shortcode!
I realize this isn’t a complete answer, but I hope the suggestion about defining an L&L variable using a custom shortcode is enough to get you started in tinkering with creating your own conditional logic statements.