As noted in my last, I didn't have time to run the code posted but in the aTbRef reference to which I linked, you'll see I'd forgotten to enclose the find() action/query code in a ^value()^ tag. This works - in that it finds things:
^include(^value(find($Prototype == "p_funky"))^,"/Templates/HTML page/HTML item")^But that filter finds every note with the 'p_funky' prototype (and every alias of those notes!). Also, doing tests using notes with names that are
designator values designator is likely to only garner strange false results. So I re-named the container 'thingx' and the children 'x 1', 'x 2' and 'x 3'. I also added a root-level exporting note 'other note' that uses the 'p_funky' prototype - as we don't want to match out-of-container scope notes.
So, adding ^value()^ in the mix, what we probably want is something like:
Code:^include(^value(find($Prototype == "p_funky"&inside($Name(that))))^,"/Templates/HTML page/HTML item")^
But (using v6.5.0) that doesn't work, though I don't know why. Knowing inside() has some not-easily-guessed logic quirks, I tried using descendedFrom($Name(that)) to see if using inside() where the issue. At which point the penny dropped.
Historically, ^include()^ was there to allow one note to import data from another, non-descendant, note of the one currently being processed. Likely it was never configured to do this sort of in-container-scope filtering - Eastgate can better answer that nuance. ^children()^ gives us all children, but not means to filter. But…
^children()^ can use a specified template for the import. So, we filter there, in the called template. Recall that if a template evaluates to nothing, nothing is returned (well some white-space may be but that's easy to tidy up once the bigger issue is resolved). Put this in the main page template:
^children("/Templates/HTML page/HTML item")^Now, the 'HTML item' template becomes:
^if($Prototype == "p_funky")^<h2>^title^</h2>
^text
^children(/Templates/HTML page/HTML item)^
^endIf^That works! If you need different output for different page types, just put more conditions here. A single ^if^ with no 'else' here offers some or no output. An if/else structure could offer a choice of two outputs (or none). If you've lots of choices and they're mutually exclusive, e.g. different prototype assignments, then you can just use lots of discrete ^if^ tests with not alternate as each tested note will only match one if test at most because a note can only have one prototype.
~~~~~~~
Template naming/references. You don't
need to cite the full path to the template. I think that in the built-in examples its a reflective hang-over from the days when templates were external text files and you had to tell TB where in the OS look Luckily that hassle is gone - all templates are in the TBX.
So, it's enough to use the title ($Name) of the template,
assuming the name is unique in the whole TBX - as templates are just a note with special characteristics. If 'HTML item' is a unique name both these work:
^children("/Templates/HTML page/HTML item")^
^children("HTML item")^
The added quotes are now best practice but the legacy quote-less version still works. As can be seen, 'HTML item' is quite possibly a title one could use in a note, so a good idea is to use prefixes - as with your prototypes. I then to use a 't_' prefix, so would probably use 't_HTML_item' though tHTML item' would do just as well. As long as it's a unique and valid name, choose a naming style that suits your style.
Sorry for the long post, but I hope the wider explanation will help folk bootstrap solving other export puzzles.