Answers.Body: <p>You could use this variable to get the template name: <code>{{ _self.getTemplateName() }}</code></p>
  
  <p>Put it at the top of all your template files: </p>
  
  <p><code>&lt;!-- {{ _self.getTemplateName() }} --&gt;</code></p>
  
  <p>And then for every template called it should have the commented out template name.</p>
  
  <p>In Craft 3, there's a nice plugin called "Template Comments" which is great for this... But I don't see a version for Craft 2.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T15:27:27.870Z
Answers.Text: Thanks.  I know what the template name is, it's give-new.twig.  The issue is, I can't tell HOW and WHERE that particular twig is invoked.  IOW, why is give-new.twig invoked and not the give.twig invoked even though both are in the same folder. Or, said another way, if I decided to create give-brand-new.twig how would I get that twig to display?
Answers.UserDisplayName: Pete Helgren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T18:55:51.693Z
Answers.Text: Hmm. I see, i was thinking it'd give context, like looking in the code so see what it's wrapped in. like if you're reading down the compiled page source, you'd see ... <!-- parent file --> ... <!-- give-new file --> ... <!-- other embedded file --> etc. And then you'd be able to see what's wrapped around it, so you'd ave a better idea where to look.
Answers.UserDisplayName: SamC
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T19:00:48.170Z
Answers.Text: Uh, additional thought. If it's not in your template code, maybe it's in your database - like there's a global or an entry field that that has "give-new" as text in it.
Answers.UserDisplayName: SamC
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T19:36:34.040Z
Answers.Text: OK...I see what you are saying in your earlier comment.  Not sure if help but I may try it.   Just to see what would happen, I just deleted the twig to see what would show up in the logs.  This is what I see:
  
  `2019/08/26 19:25:06 [error] [exception.Craft\HttpException.404] Craft\HttpException in craft\app\controllers\TemplatesController.php:72
  
  Stack trace:
  
  #0 [internal function]: Craft\TemplatesController->actionRender('_views/give-new', Array)
  
  #1 craft\app\framework\web\actions\CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)`
Answers.UserDisplayName: Pete Helgren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T19:56:03.390Z
Answers.Text: OK...I finally found it.  In Routes!  I had been looking in "Reroute" but it didn't occur to me that there would be another routing method.  Thanks for all the help..you gave me a couple of new techniques I can use
Answers.UserDisplayName: Pete Helgren
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-23T18:26:10.940Z
Answers.LastActivityDate: 2019-08-23T18:26:10.940Z
Answers.UserDisplayName: SamC
Answers.Body: <p>The solution was in "Routes" in Settings. I had been looking in "Reroute" but seem to pass over the "Routes" entry...maybe because the names were similar.  In Route there was and entry for support/give --> _views/give-new  and that was the solution.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-08-26T19:58:52.597Z
Answers.LastActivityDate: 2019-08-26T19:58:52.597Z
Answers.UserDisplayName: Pete Helgren
Body: <p>I have a page in Craft (2.x) that displays several links and I was able to find which twig file had those links by searching the code base of twigs.  Those links point to some Angular code with links like this:</p>
  
  <pre><code>/support/give?source=
  </code></pre>
  
  <p>By trial and error, I discovered that the Angular code is invoked as part of a twig file in craft/templates/_views/  The original conundrum was there were two "give" files:  give.twig and give-new.twig and I didn't know which one was the actual twig invoked.  By trail and error again, I determined it was using the give-new.twig by changing the template.  But for the life of me, I cannot figure out how THAT twig is being invoked.  I scanned for "give-new" in the code, both craft and Angular and I searched in Settings, Routes and Web Content for any reference to it but I cannot figure out how a URL like /support/give maps to the give-new.twig file.</p>
  
  <p>So the question is: How do I know which twig is invoked by a URL?  I am pretty sure that there isn't any Angular code doing this, the Angular code bundle references are in the twig file, but how that twig is invoked is a mystery.  Where do I start in finding the reference?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-22T16:14:27.680Z
Comments.Text: Check the `config/routes.php` file, see if it shows up in there.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-26T15:22:39.780Z
Comments.Text: I checked the routes.php file and it has no entries except return array();
Comments.UserDisplayName: Pete Helgren
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-26T19:59:40.613Z
Comments.Text: Should have checked Routes in settings....I would have found it there.
Comments.UserDisplayName: Pete Helgren
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-26T20:02:32.110Z
Comments.Text: Ah... you said "I searched in Settings, Routes", so I thought you had already checked that.
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-08-27T23:00:37.607Z
Comments.Text: Wow!  True...so I am not sure why I didn't see it.  Sorry.  Should have walked through what I said I did a second time before I posted.
Comments.UserDisplayName: Pete Helgren
Tags: <templating><routes><craft2>
Title: Which twig file is being used and how?
ThreadText: # Which twig file is being used and how?
  
  (Asked by: username_0 on 2019-08-22)
  
  I have a page in Craft (2.x) that displays several links and I was able to find which twig file had those links by searching the code base of twigs. Those links point to some Angular code with links like this:
  
  ```
  /support/give?source=
  
  ```
  
  By trial and error, I discovered that the Angular code is invoked as part of a twig file in craft/templates/\_views/ The original conundrum was there were two "give" files: give.twig and give-new.twig and I didn't know which one was the actual twig invoked. By trail and error again, I determined it was using the give-new.twig by changing the template. But for the life of me, I cannot figure out how THAT twig is being invoked. I scanned for "give-new" in the code, both craft and Angular and I searched in Settings, Routes and Web Content for any reference to it but I cannot figure out how a URL like /support/give maps to the give-new.twig file.
  
  So the question is: How do I know which twig is invoked by a URL? I am pretty sure that there isn't any Angular code doing this, the Angular code bundle references are in the twig file, but how that twig is invoked is a mystery. Where do I start in finding the reference?
  
  **Tags:** templating, routes, craft2
  
  > **Comments:**
  > **username_1**: Check the `config/routes.php` file, see if it shows up in there.  
  > **username_0**: I checked the routes.php file and it has no entries except return array();  
  > **username_0**: Should have checked Routes in settings....I would have found it there.  
  > **username_1**: Ah... you said "I searched in Settings, Routes", so I thought you had already checked that.  
  > **username_0**: Wow!  True...so I am not sure why I didn't see it.  Sorry.  Should have walked through what I said I did a second time before I posted.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-08-23. Score: 2
  
  You could use this variable to get the template name: `{{ _self.getTemplateName() }}`
  
  Put it at the top of all your template files:
  
  `<!-- {{ _self.getTemplateName() }} -->`
  
  And then for every template called it should have the commented out template name.
  
  In Craft 3, there's a nice plugin called "Template Comments" which is great for this... But I don't see a version for Craft 2.
  
  > **Comments:**
  > **username_0**: Thanks.  I know what the template name is, it's give-new.twig.  The issue is, I can't tell HOW and WHERE that particular twig is invoked.  IOW, why is give-new.twig invoked and not the give.twig invoked even though both are in the same folder. Or, said another way, if I decided to create give-brand-new.twig how would I get that twig to display?  
  > **username_2**: Hmm. I see, i was thinking it'd give context, like looking in the code so see what it's wrapped in. like if you're reading down the compiled page source, you'd see ... <!-- parent file --> ... <!-- give-new file --> ... <!-- other embedded file --> etc. And then you'd be able to see what's wrapped around it, so you'd ave a better idea where to look.  
  > **username_2**: Uh, additional thought. If it's not in your template code, maybe it's in your database - like there's a global or an entry field that that has "give-new" as text in it.  
  > **username_0**: OK...I see what you are saying in your earlier comment.  Not sure if help but I may try it.   Just to see what would happen, I just deleted the twig to see what would show up in the logs.  This is what I see:  `2019/08/26 19:25:06 [error] [exception.Craft\HttpException.404] Craft\HttpException in craft\app\controllers\TemplatesController.php:72  Stack trace:  #0 [internal function]: Craft\TemplatesController->actionRender('_views/give-new', Array)  #1 craft\app\framework\web\actions\CAction.php(109): ReflectionMethod->invokeArgs(Object(Craft\TemplatesController), Array)`  
  > **username_0**: OK...I finally found it.  In Routes!  I had been looking in "Reroute" but it didn't occur to me that there would be another routing method.  Thanks for all the help..you gave me a couple of new techniques I can use  
  
  ---
  
  ### Answer by username_0 on 2019-08-26. Score: 1
  
  The solution was in "Routes" in Settings. I had been looking in "Reroute" but seem to pass over the "Routes" entry...maybe because the names were similar. In Route there was and entry for support/give --> \_views/give-new and that was the solution.
  
  
  ---
  
  