How to change the selected entry in TYPO3 pagetree
Asked Answered
B

3

7

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?

Battledore answered 7/7, 2011 at 15:43 Comment(6)
Did you find a solution? Which version of TYPO3 are you relating to?Hotchkiss
Sorry, haven't found anything yet. The project in question has been neglected for a while, but seems to gain momentun again (depending on customer funding), so I'll probably look into it again somewhere the next months. I will share any solution I find. Thanks for bumping the question in my mind.Battledore
How about offering a bounty? I'd "donate" 100 Reps if you maintain this question :).Hotchkiss
This is golden, Mateng! For my part, I am still awaiting the decision of the customer in question. Sorry for not having time to look into it anyways, I am sure it would be a good contribution to the deposit of knowledge here.Battledore
Strange, still no answer. Seems to be dodgy. BTW can you include the TYPO3 version?Hotchkiss
It was implemented in 4.4.0, so it needs to be updated, which will be part of the revival of the project. It was supposed to happen before the holidays, but there is still a question as to patching vs rewriting and exactly what is to be done.Battledore
A
2

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

Aweigh answered 23/11, 2012 at 18:49 Comment(3)
OLiver, it might take some time until your suggestion is verified. I guess norwebian will let us know if this worked.Hotchkiss
@Mateng: That's fine. I'd love to know if this actually solves the issue for him or if it only looks right :)Aweigh
Thank you for your interest in my question! I just now revisited stackoverflow and saw your solution. I really appreciate it, and will take the first opportunity to test it.Battledore
M
0

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

Mecke answered 23/9, 2014 at 9:50 Comment(2)
For portabilities sake you should probably replace alt_doc.php to get the url with some utility function. Also see docs.typo3.org/typo3cms/extensions/core/8.7/singlehtml/….Lulalulea
docs.typo3.org/typo3cms/extensions/core/latest/Changelog/8.0/…Lulalulea
O
0

In TYPO3 11 fsMod has been replaced by ModuleStateStorage: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.4/Deprecation-94762-DeprecateJavaScriptTopfsModState.html

ModuleStateStorage.update('web', 123, true, '0');
Onwards answered 29/9, 2023 at 10:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.