[TYPO3-dev] Create a FE link in a BE module

Pascal Querner – MSCG pascal.querner at mscg.de
Tue Jul 7 15:47:03 CEST 2015


As a follow up to this (great answer):

If you want realURL to build awesome links for you, you really have to first render those links on the FE and then crawl that single page. That page can be accessed via a special GET parameter or something like that. Otherwise you still have ugly URLs. 

~Pascal

-----Ursprüngliche Nachricht-----
Von: typo3-dev-bounces at lists.typo3.org [mailto:typo3-dev-bounces at lists.typo3.org] Im Auftrag von Stephan Schuler
Gesendet: Montag, 6. Juli 2015 21:25
An: List for Core-/Extension development
Betreff: Re: [TYPO3-dev] Create a FE link in a BE module

Hey there.

Straight to the end: Don't. There just is no reliable to create FE links in BE environment that doesn't come with really messing with non-api stuff.

It starts with having no TSFE available in BE mode. You need lots of stuff from TSFE, like fe_user and (FE-mode!) TypoScript that are not available in BE mode. Think about language. There is sys_language_uid, sys_language_mode, language fallback and stuff.

Then there is the "enable_fields". In backend environment, you can access every record that is not deleted, within an allowed rootline (assuming you are not an administrator, if you are then this is not a limit as well) and have proper backend privileges. In frontend environment there is no allowed rootline, no backend privileges. Instead in frontend mode a link needs to consider the "hidden/disabled" mechanism as well as start time and end time. So creating a (page) link needs to consider completely different things in be and fe mode.

That's the very obvious stuff, there might be tons more details that are just different in BE and FE mode.

If you use the UriBuiler, the internal mechanisms of it just takes care of them and uses completely different ways to create uris. The UriBuilder determines which way to use by checking a constant. So as soon as the constant for "TYPO3_MODE" is set to "BE", the UriBuilder will always behave like it is supposed to be in BE mode and there is no way around it, except extending the UriBuilder and mess with its internals.

So you clearly need to go without UriBuilder.

If you can live without the UriBuilder, there might be a small chance. Boot up TSFE, fe_user, TypoScript. You most likely end up kickstarting the eID bootstrap right within a BE call. That's ... awefull.

When using extbase, you might object-access some ConfigurationManager internals, force it to FE mode and reboot configuration fetching. That's awefull, too.

Now you might have a close look at Helmut Hummels pretty awesom explanation on why using eID for nearly everything is the direct way to unpredictable errors, starting with caching hell.

So my honest advice is: Don't do FE links in BE mode. Ever.

A couple of weeks ago, I was on to creating a sitemap of a huge multi domain setup. I ended up with creating a scheduler task calling a dedicated frontend extbase page type via CURL to do the URI building.

Regards,


Stephan Schuler
Web-Entwickler | netlogix Media

Telefon: +49 (911) 539909 - 0
E-Mail: Stephan.Schuler at netlogix.de
Web: media.netlogix.de




netlogix GmbH & Co. KG
IT-Services | IT-Training | Media
Neuwieder Straße 10 | 90411 Nürnberg
Telefon: +49 (911) 539909 - 0 | Fax: +49 (911) 539909 - 99
E-Mail: info at netlogix.de | Web: http://www.netlogix.de

netlogix GmbH & Co. KG ist eingetragen am Amtsgericht Nürnberg (HRA 13338) Persönlich haftende Gesellschafterin: netlogix Verwaltungs GmbH (HRB 20634)
Umsatzsteuer-Identifikationsnummer: DE 233472254
Geschäftsführer: Stefan Buchta, Matthias Schmidt



________________________________________
Von: typo3-dev-bounces at lists.typo3.org <typo3-dev-bounces at lists.typo3.org> im Auftrag von Pascal Querner – MSCG <pascal.querner at mscg.de>
Gesendet: Montag, 6. Juli 2015 17:58
An: florian.typo3 at oktopuce.fr; List for Core-/Extension development
Betreff: Re: [TYPO3-dev] Create a FE link in a BE module

Try this

$this->controllerContext->getUriBuilder()->reset()
                    ->setArguments([
                        $this->extKey . '[uid]' => $sentence->uid]) //tx_pluginname[uid]=N
                    ->setTargetPageUid($uidOfSinglePage)
                    ->setCreateAbsoluteUri(TRUE)
                    ->buildFrontendUri();

-----Ursprüngliche Nachricht-----
Von: typo3-dev-bounces at lists.typo3.org [mailto:typo3-dev-bounces at lists.typo3.org] Im Auftrag von Florian Rival
Gesendet: Donnerstag, 18. Juni 2015 13:01
An: List for Core-/Extension development
Betreff: [TYPO3-dev] Create a FE link in a BE module

Hi,

Who knows if there's a easy way for creating FE link in a BE module
(extbase) ?
I would like to insert the link in a BE view.

Thanks,
Florian
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
_______________________________________________
TYPO3-dev mailing list
TYPO3-dev at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev


More information about the TYPO3-dev mailing list