I've had that problem when I had the templates in the same namespace as the pages that provide the data records and the page/s with datatable/s. Initially I solved it by using a filter like you. But found it simpler to put
all templates in /data/pages/templates as it also makes managing templates easier.
Example:-
Bureaucracy used to create Change control records
The page with the Bureacracy form is
/data/pages/admin/changes/start
----------------------------------------------------------------------------------------------------------
~~NOCACHE~~
=======Change Control======
=====Changes=====
---- datatable ----
cols : %title%, Change Type, Date_dt, Reason, Location, Summary
headers : ID, Type, Date, Reason, Location, Summary
filter : type=ChangeControl
----
<wrap button>
[[http://exampleserver/test/doku.php?id=admin:changes:start&do=admin&page=data_clean|Clean database]]
</wrap>
===== Add new entry to Change Control =====
<form>
Action template templates:new_changetpl "Change##Change ID##"
Number "Change ID" ++ 000
Select "Change Type" "Configuration file|Plugin|Theme|Template|Other"
Date "Date"
Fieldset "Should be a compelling reason for change"
Textbox "Reason" /^((?!<\/nowiki>).)*$/
Fieldset "Path from root of dokuwiki installation"
Textbox "Location" /^((?!<\/nowiki>).)*$/
Fieldset
Textbox "Summary" /^((?!<\/nowiki>).)*$/
Submit "Add new Change Control entry"
Thanks "[[admin:changes:start|Show updated tables]]"
</form>
----------------------------------------------------------------------------------------------------------
The page with the template is
/data/pages/templates/new_changetpl
----------------------------------------------------------------------------------------------------------
====== @!PAGE@ ======
---- dataentry changes----
Type : ChangeControl
ChangeID : Change##Change ID##
Change Type : ##Change Type##
Date_dt : ##Date##
Reason : ##Reason##
Location : ##Location##
Summary : ##Summary##
----
=====Details of change=====
<do @USER@>Add details of Change##Change ID##</do>
----------------------------------------------------------------------------------------------------------
I'm not saying it's the
right way to do it, but it is
a way.
:)