开发者

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.

The ID is changed by passing query parameter ID to the mod.php-module, and works as expected. 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. 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.

Any idea as to how to make the pagetree reflect the new $this->id?


Here's how I did it. In the PHP code of my BE module, I only called openPageTree like so:

t3lib_BEfunc::openPageTree(76,false);

I did not call setUpdateSignal because the whole "update signal" process felt a bit weird to me. Please also note that openPageTree now has a second parameter, which is required.

To my understanding, this call should be sufficient to set the state of tree in the user session server-side. Now comes the client side.

In the JavaScript code of my extension, I simply select the appropriate page ID and that's it:

<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. 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 :

/**
 * 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 :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜