Reputation: 1
I am responsible for a webpage which is using Typo3, which I did not create. Recently (and with assistance), the version of Typo3 was upgraded from 6.2 to 7.6. Since then, I have lost the possibility to include php code directly in a page, in the backend (in the same way you would add text, or images, or html). As far as I can tell, there used to be an extension to do h (php_page_content) which is not compatible with this latest version.
I have seen some examples on how to proceed on the internet (for example at https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/UserAndUserInt/Index.html), but this is fairly advanced for me, and I am unable to apply this to my problem (my skills in php are pretty much non-existent). Can someone provide assistance in this matter?
Upvotes: 0
Views: 2191
Reputation: 2243
Here is the simple stuff might be help you, try this, its working for me
Setup.ts
# Add bellow typoscrip in setup.ts
lib.content = USER
lib.content {
# Define external PHP Script file path
includeLibs = fileadmin/function.php
# Call user function
userFunc = getData->GetNewsCountInCat
# Pass your argument to the php scrpt (Here function.php)
value = This is the value
}
function.php
Your PHP logic goes Here (Path: fileadmin/).
class getData
{
// Initialise cObject
public $cObj;
public function GetNewsCountInCat($content, $conf=array()) {
// Get argument
$arg = $this->cObj->TEXT($conf);
echo $arg;
}
}
Now you can access lib object in your html with:
<f:cObject typoscriptObjectPath="lib.content" />
Your output will be:
This is the value.
However, includeLibs
has removed from TYPO3 version 8. You can use USER and USER_INT with a higher version. Find the URL below:
Greetings!
Upvotes: 4
Reputation: 28
You can use few available extensions like https://typo3.org/extensions/repository/view/pe_pagephpcontentelement
Upvotes: 0