TYPO3 12 News backlink to list view section

69 views Asked by At

I'm currently running TYPO3 12 on my one page website, which includes a news section. To get to the news section you have to scroll down a bit. This is fine so far. The problem is with the backlink in the detail view. As it stands currently, whenever you go to the detail view of a news article and use the backlink, you have to scroll back down to the news section.

Please note that this OnePager has all sections on a single page in the backend. So there's only the page "Home" which contains all sections like "Hero image", "News", "Contact" and so on.

So I would like to add the correct anchor link to my backlink, so that you don't have to scroll back down. To get the correct anchor link, I need to have the cObjectUid of the list view. How would I go about passing the cObjectUid from the list view to the detail view?

Here's a small illustration. The red arrow shows how the backlink currently behaves, and the green arrow how I want it to be. enter image description here

I've tried adding a few additional arguments to the link and passing them on in the controller, but so far no success.

Here's my current code for the link, linking to the detail view:

<n:link newsItem="{newsItem}" settings="{settings}" title="{newsItem.title}">
    Some text
</n:link>

And here's my current code for the backlink:

<f:link.page pageUid="{settings.backPid}">
    Sometext
</f:link.page>

Edited for clarity

1

There are 1 answers

3
Paradonix On

So I've figured out a way to solve my problem, but in my opinion it's not ideal, which is why I won't mark this as solved just yet.

I adjusted the detail view link and added the cObjectUid as an additional parameter to the URL:

<n:link newsItem="{newsItem}" settings="{settings}" configuration="{additionalParams:'&tx_news_pi1[listUid]={uid}'}" title="{newsItem.title}">
    Sometext
</n:link>

Inside the Controller I can now grab that argument and assign it to the detail view.

$additionalArguments = $this->request->getArguments();
$listUid = $additionalArguments['listUid'];
$assignValues['listUid'] = $listUid;

if (count($assignValues) > 0) {
    $this->view->assignMultiple($assignValues);
}

With this I can assign the correct HTML ID to the backlink.

However, there are still two problems with this:

  1. If the URL doesn't contain the additional arguments, the backlink will no longer link to the correct section.
  2. The URL doesn't look all that nice.