Is there a method for returning the name of the template that is assigned to a given page ID/alias?
Thanks.
[solved] Get name of template assigned to page
[solved] Get name of template assigned to page
Last edited by Cerulean on Wed Sep 09, 2015 10:28 pm, edited 1 time in total.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Get name of template assigned to page
From the API it's quite simple. You did not provide any context so I will assume you mean from the PHP realm.
Once you have the content object, you can get the design id and the template id.
Once you have the design id, you can load the design object and get it's name.
It is the same with the Template object.
of course you must do error checking at each step along the way. The newer CmsLayoutTemplate and CmsLayoutDesign classes will throw exceptions if you try to request an object given invalid data. Some of the older methods will not.
Once you have the content object, you can get the design id and the template id.
Once you have the design id, you can load the design object and get it's name.
It is the same with the Template object.
Code: Select all
$hm = CmsApp::get_instance()->GetHierarchyManager();
$node = $hm->sureGetNodeByAlias($the_content_id_or_alias);
$content_obj = $node->GetContent(TRUE);
$template_id = (int) $content_obj->TemplateId();
$design_id = (int) $content_obj->GetPropertyValue('design_id');
$template = CmsLayoutTemplate::load($template_id);
$template_name = $template->get_name();
$design = CmsLayoutDesign::load($design_id);
$design_name = $design->get_name();
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.