简体   繁体   English

如何更改 TYPO3 页面树中的选定条目

[英]How to change the selected entry in TYPO3 pagetree

I am making a backend extension that, changes which page it is working on upon clicking a link in the work area to the right of the pagetree.我正在制作一个后端扩展,通过单击页面树右侧工作区域中的链接来更改它正在处理的页面。 The problem is: the pagetree doesn't update according to the ID that is presented in the work area.问题是:页面树不会根据工作区中显示的 ID 进行更新。

The ID is changed by passing query parameter ID to the mod.php-module, and works as expected. ID 通过将查询参数 ID 传递给 mod.php 模块来更改,并按预期工作。 I have tried updating the page tree via我尝试通过更新页面树

   t3lib_BEfunc::openPageTree($this->id);
   t3lib_BEfunc::setUpdateSignal('updatePageTree');

and later然后

   <script type="text/javascript">'.t3lib_BEfunc::getUpdateSignalCode().'</script>

to be included in the output.包含在 output 中。 This also works (the pagetree is refreshed, and hidden subpages of the passed ID is revealed), except the greyness indicating the current page in the page tree is left at its previous position.这也有效(刷新页面树,并显示所传递 ID 的隐藏子页面),除了指示页面树中当前页面的灰色保留在其先前的 position 处。

Any idea as to how to make the pagetree reflect the new $this->id ?关于如何使页面树反映新的$this->id的任何想法?

Here's how I did it.这就是我的做法。 In the PHP code of my BE module, I only called openPageTree like so:在我的 BE 模块的 PHP 代码中,我只像这样调用openPageTree

t3lib_BEfunc::openPageTree(76,false);

I did not call setUpdateSignal because the whole "update signal" process felt a bit weird to me.我没有调用setUpdateSignal ,因为整个“更新信号”过程对我来说有点奇怪。 Please also note that openPageTree now has a second parameter, which is required.另请注意, openPageTree现在有第二个参数,它是必需的。

To my understanding, this call should be sufficient to set the state of tree in the user session server-side.据我了解,这个调用应该足以在用户 session 服务器端设置树的 state。 Now comes the client side.现在是客户端。

In the JavaScript code of my extension, I simply select the appropriate page ID and that's it:在我的扩展程序的 JavaScript 代码中,我只需 select 适当的页面 ID,就是这样:

<script type="text/javascript">
  if (top && top.TYPO3.Backend.NavigationContainer.PageTree) {
    top.TYPO3.Backend.NavigationContainer.PageTree.select(76);
  }
</script>

While looking through the source of the page tree, I realized that it will always select top.fsMod.recentIds['web'] after a refresh.在查看页面树的源代码时,我意识到刷新后它总是 select top.fsMod.recentIds['web'] Sadly, I wasn't able to determine how to properly inject a value there.可悲的是,我无法确定如何在那里正确注入价值。 It seemed to me like the value is only supposed to be adjusted through user interaction (meaning, the user clicked on a node in the page tree).在我看来,该值似乎只能通过用户交互来调整(意思是用户点击了页面树中的一个节点)。

In TYPO3 6.1, you have a Javascript function to jump to a web module:在 TYPO3 6.1 中,您有一个 Javascript function 可以跳转到 Z2567A5EC9705EB7AC2DZZ940E 模块:

/**
 * jump the backend to a module
 */
function jump(url, modName, mainModName, pageId) {
    if (isNaN(pageId)) {
        pageId = -2;
    }
    // clear information about which entry in nav. tree that might have been highlighted.
    top.fsMod.navFrameHighlightedID = [];
    top.fsMod.recentIds['web'] = pageId;

    if (top.TYPO3.Backend.NavigationContainer.PageTree) {
        top.TYPO3.Backend.NavigationContainer.PageTree.refreshTree();
    }

    top.nextLoadModuleUrl = url;
    top.TYPO3.ModuleMenu.App.showModule(modName);
}

You can use it like this:你可以像这样使用它:

<a onclick="jump('alt_doc.php?&edit[pages][\'uid_page\']=edit','web_list', 'web', 'uid_page')" href="#"><span class="t3-icon t3-icon-actions t3-icon-actions-document t3-icon-document-open">&nbsp;</span></a>

Just replace "uid_page" by your correct uid:)只需用正确的 uid 替换“uid_page”即可:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM