TYPO3 backend deeplink to page record - typo3

I am using version 8.7 of TYPO3 and intended to use a link that leads directly to the backend to edit a record (page). I tried anything like typo3/backend.php?edit=57 but got a error:
file not found

typo3/backend.php?edit=57 was the way to do it up until TYPO3 6.2, but the backend URL changed to typo3/index.php in TYPO3 7.6. It still works kind of, however you need a security token which is generated by the core. The URL now is typo3/index.php?route=%2Fmain&edit=57&token=.... There isn't really an easy way to generate URL with a valid token like that from outside TYPO3 though.
If you want to create a link inside a custom module to edit a record you can use \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick() or if you're using a Fluid template, the \TYPO3\CMS\Backend\ViewHelpers\Link\EditRecordViewHelper ViewHelper. More on that you can find here: https://docs.typo3.org/typo3cms/CoreApiReference/8.7/ApiOverview/Examples/EditLinks/

Using the extension pxa_siteimprove deep links are of the following form:
https://example.com/typo3/index.php?tx_siteimprove_goto=page:{page_uid}:{language_uid}
The parameter language_uid is optional. An example link to a page with uid 42 looks like this:
https://example.com/typo3/index.php?tx_siteimprove_goto=page:42
Optionally we can include a language uid (e.g. 1). Without a language uid set it defaults to 0:
https://example.com/typo3/index.php?tx_siteimprove_goto=page:42:1
If you want to create deep links for other purposes, you can look how this extension creates the deep link in Pixelant\PxaSiteimprove\Hooks\DeepLinkingHandler. In a first hook it just saves the page uid to the backend user session and in a later hook reuses this information to redirect to the desired page by setting the following global variable:
$GLOBALS['BE_USER']->uc['startModuleOnFirstLogin'] = 'web_layout->id=' . (int)$pageId . '&SET[language]=' . (int)$languageId;

Related

How to use the keyword "location" in the URL parameter in AWS Amplify

I am currently working on a 1 page HTML app that uses URL parameters to do an API call. the URL parameters are set and used in QR codes so its necessary that they are able to change dynamically. A example URL would be something like app.com/index.html/?environment=demo&location=Kiosk
I currently have this app deployed in AWS Amplify, but I cant get other keywords to chain together. I have the following redirects in place:
These redirects make sure that every URL parameter I pass in the link works EXCEPT some keywords like the "location" keyword, next to some others. Using this keyword as a URL param gives a 502 server error, or if the redirects are not used an access denied error.
does anyone know how to get the location keyword to work? Thanks in advance!
You should be able to use a single rule that will forward everything to index.html EXCEPT urls with a "file extension" from the list below. That lets all your links work, but assets like images, fonts, code will pass through.
Doc for: Using Redirects - Single Page Apps
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json)$)([^.]+$)/>

TYPO3: How to use an external PHP Script (in fileadmin), where i can check the cookie

I'm using TYPO3 11.3.3 for my server and i need a PHP Script, that can read and check the typo3_fe cookie. Are there any solutions? I can't use an extension and I have to keep it simple.
What exactly should the PHP script do apart from reading the cookie?
You can use a TypoScript condition to check if the cookie is present:
[request.getCookieParams()['foo'] == 1]
See the documentation for details.
The only way would be a content object USER. Check out the documentation.
Example
page = PAGE
page.10 = USER_INT
page.10 {
userFunc = Vendor\ExtensionName\ExampleTime->printTime
}
However the doc also states
The property includeLibs has been removed in TYPO3 8.0. In earlier
versions the userFunc classes were sometimes stored in fileadmin/ -
this is no longer possible out of the box and not recommended.
For the best result you should always, without exception, place your
class files in an extension, define composer class loading for this
extension and add this extension as a dependency of your project.
Then, your classes will load without issues when you refer to them by
their class name.
Cookies are being sent along with the request. With that being said, the best way to check for the cookies is Middlewares. With the middlewares you can check for the sent cookies and evaluate them with your script.
Here is the documentation about middlewares.
This might be helpful as well https://stackoverflow.com/a/63951593/7162477
Best regards

eID REST interface with authentication in Typo3

I'm providing an eID page as an REST interface. Now I want to protect this page with an API key or similar. How can this be achieved in Typo3 8.7?
Actually it looks like this can only be done by logging in via frontend (FE) or backend (BE) and check the login status in the eID controller class.
For TYPO3 v8, you should check out the EXT:restler extension instead of using eID.
eID is meant for calls where you have to do basically everything on your own.
For TYPO3 v9, the PSR-15 middleware concept allows to individually build custom REST APIs and integrations with other solutions like SlimPHP: https://github.com/b13/slimphp-bridge
You can expect a given URL-paramter, maybe even as a post param.
Put your eID-page-configuration (typoscript) in a condition requesting this paramter to be set. Otherwise genate an error-page.
If you want to handle multiple keys (maybe from a database table) you could use a userfunc for conditions.
If you want to handle a login in the call you need to initialize more from the TYPO3 frontend. then identify the paramters from the login form (some are hidden) and provide them. AFAIK POST and GEt paramaters work.

Get the current page url inside a hook for contao

I am using the parseArticle hook for news module for my contao instance. I need to get the current page url inside this parseArticle hook. I had checked with the insert tags "{{env::url}}". But it's not working. It is simply displaying this text. Is there any way to use insert tags inside our hook?
If no, what should be done to get the page url inside that hook for contao?
You can retrieve the current URL via \Environment::get('uri'). This also includes the query string.
In general you can also "use insert tags" this way: \Controller::replaceInsertTags('{{…}}'), but this should never be necessary.
If you want the url to the reader page (without the news item in the URL), you can use
global $objPage
$strRelativeUrl = $objPage->getFrontendUrl();
$strAbsoluteUrl = $objPage->getAbsoluteUrl();
Both of these function can take parameters to add to the URL. See PageModel.php#L1013 for example.
Or use
\Environment::get('url');
Found on https://www.marcosimbuerger.ch/tech-blog/contao-environment-klasse-mit-beispielen.html

Get displaytag to use an action URL for page switching

I'm trying to use external paging in a JSR-286 portlet with DisplayTag 1.2.
I would like DisplayTag to generate the paging links from a parameterized Action URL that i have defined, but i can't seem to make that work.
Here is the code in my JSP:
<portlet:actionURL var=actionUrl >
<portlet:param name="someParam" value="someValue" >
</portlet:actionURL >
<display-el:table id="personsTable"
name="${portletSessionScope.persons}"
requestURI="${actionUrl}"
partialList="true"
size="${portletSessionScope.total}"
pagesize="${portletSessionScope.pageSize}" >
<display-el:column property="firstName"/ >
</display-el:table >
With the above code, it looks like Display-tag ignores the provided ${actionUrl} and generates a default Render URL. The generated links work fine (i can move through pages), but since my portlet requires an Action request to fetch other pages of data, the list in the session is never updated and the table always contains the same data, regardless of which page i select.
Is there a way i might make that work? Does DisplayTag support what i'm trying to do?
Thanks in advance for your help!
Create a form in your JSP and pass the form name to the displaytag:table as form attribute value. This will invoke the action URL that you have specified.