Umbraco 4 文件服务
Umbraco 4 FileService
正如 Umbraco 4 Fileservice 的名称所述,但我认为 FileService 不能在 Umbraco 4 上运行。
我有一个 Umbraco 4 项目,我需要在其中获取所有模板,我需要提取它们的名称、别名、父模板和内容供个人使用,但我不知道如何获取所有这些,在Umbraco 6 和 7 使用 FileService 很容易,但我使用的是 Umbraco 4。
我希望这里有人可以帮助我在 Umbraco 4 中做到这一点,因为我真的需要获得所有这些模板,不仅是模板,还有一些项目,如宏脚本。
(请不要建议创建我不想使用的包)
非常感谢
如果您t/won不会使用 uSync,则需要编写自己的代码来执行此操作。 FileService 是在 6 中引入的,所以它在 4 中不起作用。
要在代码中获取所有模板,您可以这样做:
var templates = umbraco.cms.businesslogic.template.Template.GetAllAsList();
foreach (var item in templates)
{
//template alias
item.Alias;
//parent id
item.ParentId;
//the path to the master file so you can get using system.io
item.TemplateFilePath;
//the name of the template
item.Text;
}
正如 Umbraco 4 Fileservice 的名称所述,但我认为 FileService 不能在 Umbraco 4 上运行。
我有一个 Umbraco 4 项目,我需要在其中获取所有模板,我需要提取它们的名称、别名、父模板和内容供个人使用,但我不知道如何获取所有这些,在Umbraco 6 和 7 使用 FileService 很容易,但我使用的是 Umbraco 4。
我希望这里有人可以帮助我在 Umbraco 4 中做到这一点,因为我真的需要获得所有这些模板,不仅是模板,还有一些项目,如宏脚本。
(请不要建议创建我不想使用的包)
非常感谢
如果您t/won不会使用 uSync,则需要编写自己的代码来执行此操作。 FileService 是在 6 中引入的,所以它在 4 中不起作用。
要在代码中获取所有模板,您可以这样做:
var templates = umbraco.cms.businesslogic.template.Template.GetAllAsList();
foreach (var item in templates)
{
//template alias
item.Alias;
//parent id
item.ParentId;
//the path to the master file so you can get using system.io
item.TemplateFilePath;
//the name of the template
item.Text;
}