我有两个外部链接,我需要通过两个不同的模板(标准,打印模式)显示文档(Pagetitle和TV)中的信息。有解决方案吗?
谢谢!
您需要使用所需模板为此资源创建符号链接。https://rtfm.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/site/site/symlink/symlink/susing-resource-symlinks
upd:
<?php
$from_parent_id = 8; // Test 1 dir id
$to_parent_id = 9; // Test2 dir id
$to_template_id = 2; // Template id of newly created symlink
if ($modx->event->name == 'OnDocFormSave') {
if ( $mode == modSystemEvent::MODE_NEW ) {
$parent = $resource->get('parent');
if ($from_parent_id == $parent) {
$fields = array(
'template' => $to_template_id,
'content_type' => 1,
'class_key' => 'modSymLink',
'context_key' => 'web',
'parent' => $to_parent_id,
'richtext' => 0,
'hidemenu' => 0,
'published' => 1,
'searchable' => 0,
'cacheable' => 1,
'content' => $id,
);
$new_resource = $modx->newObject('modSymlink', $fields);
$new_resource->save();
}
}
}
也许Modx额外的SwitchTemplate是您需求的选项?
此额外的内容通过请求参数即时更改MODX资源模板。它可以由MODX后端的软件包管理安装。