MichaMichaMicha Posted May 20, 2013 Posted May 20, 2013 Module: TemplateHasTags Simple Module that provides a method for checking if the current template has got (or has not got) one or more specific template tags. Wanted to control the visibility for some blocks on the frontend in the backend without modifying the code. This seemed to be the best way. Returns true if the currently used template: --has the tag "detail" but not "special"$page->hasTags("detail !special");--does not have the tag "listview"$page->hasTags("!listview");You can also use $page->hasTag("lorem ipsum"); Module link 6
owzim Posted May 20, 2013 Posted May 20, 2013 I don't understand this =) Can you present a use case more specifically? When talking about "template tags" do you mean regular html tags?
MichaMichaMicha Posted May 20, 2013 Author Posted May 20, 2013 I don't understand this =) Can you present a use case more specifically? When talking about "template tags" do you mean regular html tags? Check out the Advanced tab in a template detail view. There is a field called tags. You can use it to group templates in the Templates List. I used to use a regex each time to check for the presence (or absence) of a tag, but now I have this Module so it's more solid.
owzim Posted May 20, 2013 Posted May 20, 2013 Ah sorry, template tags, yeah. Get it now. Great stuff!
MichaMichaMicha Posted May 20, 2013 Author Posted May 20, 2013 While creating this Module I realized maybe this should be included in the Selectors? Ryan, what do you think? Or maybe it is more a visual representation and it should not be used like this?
kongondo Posted May 20, 2013 Posted May 20, 2013 Micha, Thanks for this module. For reference for all reading this, these "tags" have been discussed previously in this thread: http://processwire.com/talk/topic/2689-possible-to-get-field-tags/. See Ryan's thoughts on post #21. 2
MichaMichaMicha Posted May 20, 2013 Author Posted May 20, 2013 Micha, Thanks for this module. For reference for all reading this, these "tags" have been discussed previously in this thread: http://processwire.com/talk/topic/2689-possible-to-get-field-tags/. See Ryan's thoughts on post #21. Thanks, nice to see someone was thinking the same.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now