Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the selected entry in TYPO3 pagetree

Tags:

typo3

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?

like image 589
norwebian Avatar asked Jul 07 '11 15:07

norwebian


1 Answers

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

like image 181
Oliver Salzburg Avatar answered Oct 14 '22 03:10

Oliver Salzburg