We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Display template group name and template name in template?

Development and Programming

Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Hey guys,

I was wondering if there was a way to display the current template group name and template name in a template?

EG: This page is using {template_name} in {template_group_name}.

Cheers

Moved by Moderator

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

I don’t think so. Personally, I’d be most interested in {template_id}, but see what Rick had to say in repsonse to my feature request.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Ok after looking through the code I think I may have a solution that returns:

template_id template_name template_group template_group_id

turning it into a plugin now 😊

Care to test?

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
17 years ago
Sue Crocker's avatar Sue Crocker

Sure.. I can test it this morning..

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

Just gave it a quick run, and it works nicely, including multiple sites (using path.php, not the MSM) and using default values for both template_group and template (using something like example.com/index.php/url_title, which I generally tend to avoid.) Works with categories, too.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Excellent… I made sure every sql statement had a site id clause 😊

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
17 years ago
Robin Sowell's avatar Robin Sowell

Nice one- want me to shift this down to plugins? Or close it out here?

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham
Nice one- want me to shift this down to plugins? Or close it out here?

Yeah this one could be o\moved to plugins now I have the solution 😊

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Of course you don’t even need this plugin if you use some variables in you embed

{embed="_includes/.head" tg="template_group" t="template"}
       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

Yes, but that’s hardcoding them, something I alway try to avoid.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham

Hey guys,

In response to this thread I have released LG Template Info with full documentation.

As usual its available on my site: LG Template Info - Display ExpressionEngine Template information in your templates.

Enjoy

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
17 years ago
Ingmar Greil's avatar Ingmar Greil

I’ve tested it, and it wokrs fine. Nice work, Leevi.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.