You’re running into issues with parse order here. I’d recommend downloading this PDF as a great reference.
Let’s take a step back a bit and get a bigger look at this. What are you looking to achieve here? What are these snippets accomplishing on the page?
Thanks, Kevin - I’ll take a look at that PDF.
Re bigger look at this - essentially, I’m trying to reduce my template and snippet collection from what I think is too many down to ... well ... less. 😊
I used to have a snippet named “snippet-<section>” where <section> is the specific title of the page being displayed. It meant that I needed to check {segment_2} and, based on what it is, show the appropriate snippet. It made the templates messy and far too big, not to mention duplicating some markup, too. This was all done when I was just starting this site and before I knew anything about the conditionals etc.
I’ve managed to make one of the primary culprit templates much better by using something like this:
{exp:channel:entries channel="whatever" url_title="{segment_2"} dynamic="no" disable="categories"}
That does work a lot better as it means I don’t have to check the {segment_2} value, provided it is valid (if not, the 404 template is shown, of course).
The original question above was me trying to set a variable that matched the name of the required snippet before I tried putting the url_title into the exp:channel:entries tag, something that does seem to work OK.
All that said, I’m simply trying to make the site more efficient and also so that the one of the non-technical admins of the site can add content without me having to create a snippet then check that it exists inside the template (super messy).
Apologies if that makes no sense. 😊