I bumped into this yesterday:
http://ellislab.com/expressionengine/user-guide//templates/globals/preload_replacement.html
If I’m reading this correctly, I can swap in whole lines of code, pre-parsing. What does this make me happy?
Well, for example, I could parse the URL segments (per the example at the bottom of the docs page), create my {exp:channel:entries} “query” (e.g., limit=...category=..., etc), and then let traditional EE kick in. So instead of having to use the same block of markup across 3 different loops/queries I can have one block of markup and use preload_replacement to inject the correct “query” on the fly.
This might also be useful if the same custom field names were used across two or more channels. Same display, but what matters is the one line that defines the EE select.
1) Am I reading into this correctly?
2) Has anyone else done this? Are there any tips and tricks I need to know before I begin?
3) Is there a way - based on EE parsing order - to trick this into working across more than one template? That is, instead of having to retest and reconstruct the EE select string for each template I can some how do it once in the header and then cascade that down the page. Ok, maybe that’s a pipe dream but it doesn’t hurt to ask, eh?
Another example, I tend to put my pages in one weblog and my blog content in another. Yeah, I know, duh? 😊 Each has custom fields for meta title, og:title, etc. Now instead of having to code for each weblog I can use the same field names in both channels and define the {exp:channel:entries…} by using conditionals on the segments. Bingo! One EE select can work on many channels, yes?