Repeater - filter out Template with WHERE

Michael D asked on October 29, 2019 19:23

Hello,

Is it possible to filter out certain Templates in a Repeater? I'm trying to use the WHERE cause to do this but I'm having trouble finding the correct syntax to use.

I've tried:

  • NodeTemplateID NOT LIKE 'Forms'
  • {%NodeTemplateCodeName%} NOT LIKE 'Forms'
  • and others along the same lines

Thanks

Recent Answers


Peter Mogilnitski answered on October 29, 2019 20:32

Can you share the query that you are using in your repeater?

0 votesVote for this answer Mark as a Correct answer

Michael D answered on October 29, 2019 20:53

I'm not using a query exactly. I'm using the Repeater web part and filling in the fields. Everything works but I'm wondering if there's a way to exclude CMS.MenuItem with a certain template.

I'm thinking there would be a WHERE statement but i'm not sure on the syntax.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on October 29, 2019 21:11 (last edited on October 29, 2019 21:13)

It is a bit tricky (because template could be inhereted), I would rather add a new Boolean field (IsHidden or smth) to CMS.MenuItem and set to false by default and set to true for your specific page. Then your Where will be simple IsHidden = 1

P.S. 4 fields in view_cms_tree_join that determine the template

NodeTemplateID
NodeTemplateForAllCultures
NodeInheritPageTemplate
DocumentPageTemplateID

to figure out it possible by it is tricky

1 votesVote for this answer Mark as a Correct answer

Michael D answered on October 29, 2019 21:14

So, as far as you know, there's nothing like: WHERE TemplateCodeName != 'FormTemplate'

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on October 29, 2019 21:54 (last edited on October 29, 2019 21:55)

You can do something but there is inheritance and where could be complicated. if you are sure that the template is assigned directly to this particular cms.menuitem page and note inhereted from the parent, you can do something like

(isnull(NodeInheritPageTemplate,0) = 0 AND  NodeTemplateID <> (select PageTemplateId from cms_pagetemplate where pagetemplatecodename  = 'FormTemplate'))  
AND 
(isnull(NodeInheritPageTemplate,0) = 0  AND NodeTemplateID <> (select PageTemplateId from cms_pagetemplate where pagetemplatecodename  = 'FormTemplate')) 

but I would recommend the solution with boolean field

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.