Editing Typo3 CMS front-end page - typo3

I get a project that used TYPO3 CMS, the task is quite simple, adding cookie usage notice on the header part of the website.
I never working on TYPO3 before, but already reading the documentation. Somehow I can't figure out which file to edit. even the documentation tutorial and file structure is different than the project I handle.
I don't have any project documentation for the project either, and I don't want to ask you to do my task, but I'm blank at the moment and don't know where to find the respective file needed.
Any suggestion or clue how to handle the issue?
my index.php on root folder look like this:
if (defined('E_DEPRECATED')) {
error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
} else {
error_reporting(E_ALL ^ E_NOTICE);
}
// ******************
// Constants defined
// ******************
define('PATH_thisScript', str_replace('//', '/', str_replace('\\', '/',
(PHP_SAPI == 'fpm-fcgi' || PHP_SAPI == 'cgi' || PHP_SAPI == 'isapi' || PHP_SAPI == 'cgi-fcgi') &&
($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) ?
($_SERVER['ORIG_PATH_TRANSLATED'] ? $_SERVER['ORIG_PATH_TRANSLATED'] : $_SERVER['PATH_TRANSLATED']) :
($_SERVER['ORIG_SCRIPT_FILENAME'] ? $_SERVER['ORIG_SCRIPT_FILENAME'] : $_SERVER['SCRIPT_FILENAME']))));
define('PATH_site', dirname(PATH_thisScript).'/');
if (#is_dir(PATH_site.'typo3/sysext/cms/tslib/')) {
define('PATH_tslib', PATH_site.'typo3/sysext/cms/tslib/');
} elseif (#is_dir(PATH_site.'tslib/')) {
define('PATH_tslib', PATH_site.'tslib/');
} else {
// define path to tslib/ here:
$configured_tslib_path = '';
// example:
// $configured_tslib_path = '/var/www/mysite/typo3/sysext/cms/tslib/';
define('PATH_tslib', $configured_tslib_path);
}
if (PATH_tslib=='') {
die('Cannot find tslib/. Please set path by defining $configured_tslib_path in ' . htmlspecialchars(basename(PATH_thisScript)) . '.');
}
// ******************
// include TSFE
// ******************
require (PATH_tslib.'index_ts.php');
edit: adding screenshot of the interface suggested by #Riccardo (typo3 ver 4.4.4)

Which version of TYPO3 are you running? As Bernd wrote, it is difficult to help you without further information.... I'll try to explain the first passages where you could gather some infos.
1) Access TYPO3 backend with a user with administrative privileges
2) Try to identify the main TypoScript template with this procedure:
click on template (1)
click on the "zero" page with the TYPO3 symbol (2)
you should see on the right a list of the TypoScript templates (3),
click on the one that is marked as "is Root"
2) After that, click on the first dropdown on the right area (with the "info/modify" item and select "TypoScript Object Browser" (a.k.a. TSOB)
3) After you have done that, you should see a "tree" that represents the TypoScript configuration;
be sure to have "setup" selected (1)
search for the object that builds your page, which should most likely be page = PAGE (2)
[answer edited]
I'm afraid I'll have to ask for a survey supplement
Can you identify in which part of the various objects the header of your site is rendered? My suspects would be focused on the [home2] or the [outer_frameset] object;
Hoping that they will contain the usual array with something like:
home2.10 = something
I think that the quickiest (and dirtiest) way to append something before the whole page would be something like
home2.1 = TEXT
home2.1.value = <div>whatever your message would be </div>
I don't know if you need something more complex than that...
Said that, I admit I never worked with frame inside TYPO3 and I think that the last time I did something with frames was...uh... maybe 9 years ago.

Don't change that index.php!!
As it is part of the core which gets overwritten on an update of TYPO3.
As there are very much options for configurating a page there can be no recipe matching all.
My best tip: get a TYPO3 profi to have a look into your installation so he can find which files are responsible for the page rendering and could include the cookie notice.
There also are some extensions which could render such a notice in your pages in a very easy way. But that all depends how your installation is configured. Nothing to say without further knowledge.

Related

TYPO3 v11.5 #1578950324 RuntimeException - The given page record is invalid. Missing uid. Backendmodul

After upgrading to TYPO3 v11.5, I get this error in my extensions backend module:
1578950324 RuntimeException
The given page record is invalid. Missing uid.
So I digged a little deeper and found out that this has to do with using the f:be.tableList ViewHelper.
In my BE module I use the ViewHelper like this:
<f:be.tableList
tableName="tx_myext_domain_model_mymodel"
storagePid="1"
fieldList="{0: 'column1', 1: 'column_2'}"
sortField="column1"
enableControlPanels="true"
clickTitleMode="edit" />
Since I register my backend module with 'navigationComponentId' => '', (as mentioned in the documentation) I get this error. But the page tree or something else isn't helpful at this point, so I don't want to show them.
(If I show the page tree with 'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement', this error disappears)
It turned out that the ViewHelper checks if the user has access rights via checking if the PID is in the mountPoint. I think this is important and not a bug. Fixing that issue could be hard, because how to check the mountPoint permissions if I don't know the PID. (maybe in the ViewHelper: check against the storagePid?)
But if you disable the page tree, there is no PID to check against.
So I also found out, the current PID is fetched while TYPO3\CMS\Core\Utility\GeneralUtility looks for a given id like this:
$value = $_POST[$var] ?? $_GET[$var] ?? null;
I didn't found a way to set the pid in my Extbase Controller, so I did it easily this way in my listAction:
if( TYPO3_MODE == 'BE' ) {
// if is in the BE-module, set PID to prevent customer authentication check error
$_POST['id'] = 1;
}
(In this case, I set the PID to my rootpage.)
If someone has a better solution, don't hesitate to post it to this question.
Have you disabled the page tree for the backend module? If yes - that's the problem! The settings inheritNavigationComponentFromMainModule => false leads to the error.

Typo3 RealURL: show page id

I want to use RealUrl extension in my typo3 site.
What I want to do:
change the usual url
"http://mysite.it/pag/index.php?id=1"
into
"http://mysite.it/pag/1"
(I wanto to hide "index.php?id=")
Is it possible to do it using RealUrl? Can someone help me? (conf example)
Thank you
In this way you probably do not need realurl.
Any url of type https://mydomain.tld/?{pageid} will be mapped by TYPO3 core to index.php?id={pageid} so you need just a small htaccess rewrite to insert the questionmark.
It is just that links are not generated in this short form. But that could be done by a lastplace replacement (do a stdWrap.replacement on the PAGEobject):
page = PAGE
page {
10 = ...
:
stdWrap.replacement {
1.search = index.php?id=
1.replace =
}
}
Your request reminds to the core-extension simulate static, but that might be obsolete and the pattern differs from your request. It was https://mydomain.tld/{pagetitle}.{pageid}[.{pagetype}].html. For the default-pagetype 0 the pagetype does not need to render.

Adding defer attribute in .js files included in moodle

I am optimizing the performance of my Moodle site, it is showing the high loading time on loading the .js files of the page. That is why I want to include the defer='defer' attribute in the page which is calling or including the javascript files as follow.
if (!empty($CFG->cachejs) and !empty($CFG->jsrev) and $CFG->jsrev > 0 and substr($url, -3) === '.js') {
if (empty($CFG->slasharguments)) {
return new moodle_url($CFG->httpswwwroot.'/lib/javascript.php', array('rev'=>$CFG->jsrev, 'jsfile'=>$url));
} else {
$returnurl = new moodle_url($CFG->httpswwwroot.'/lib/javascript.php');
$returnurl->set_slashargument('/'.$CFG->jsrev.$url);
return $returnurl;
}
} else {
return new moodle_url($CFG->httpswwwroot.$url);
}
So how can I add the defer='defer' attribute on this? Please suggest me.
there are multiple locations where javascript is embedded in the Moodle page, the biggest one is for the YUI3 library.
To add the defer tag, look in file /lib/outputrequirementslib.php. The exact line number depends on your Moodle version. The trickiest one is to add it to the static.js as this is handled in the html_writer class.
Please note that the tag should be "defer" and not "defer='defer'" as Moodle uses the HTML5 doctype.
Also the loading order for Moodle is important due to the way they have build it. Adding the defer attribute will probably break your Moodle.

Typo3 eID, how to access config

I've just created an eID in Typo3. I can't figure out how to access the config data for my plugin from the Typo3 instance.
I've tried the code from the link but it doesn't want to work. I keep getting an exception "No TypoScript template found! " on the call " $TSFE->getConfigArray(); "
http://lists.typo3.org/pipermail/typo3-dev/2006-December/021392.html
Any ideas?
Thanks.
In eID mode, only a small part of the regular TYPO3 frontend is loaded. Unfortunately TypoScript is not loaded. To still access the TypoScript configuration you need manually load the components it needs to do so. Unfortunately this can be a bit of a pain in the butt. So in some cases it might be easier to just load a page containing a single plugin that doesn't contain anything else (without headers etc.).
If you do want to load the TypoScript templates yourself, you can try something like the following:
require_once(PATH_tslib.'class.tslib_fe.php');
require_once(PATH_t3lib.'class.t3lib_userauth.php' );
require_once(PATH_tslib.'class.tslib_feuserauth.php');
require_once(PATH_t3lib.'class.t3lib_cs.php');
require_once(PATH_tslib.'class.tslib_content.php') ;
require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
$TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
$id = isset($HTTP_GET_VARS['id'])?$HTTP_GET_VARS['id']:0;
$GLOBALS['TSFE'] = new $TSFEclassName($TYPO3_CONF_VARS, $id, '0', 1, '','','','');
$GLOBALS['TSFE']->connectToMySQL();
$GLOBALS['TSFE']->initFEuser();
$GLOBALS['TSFE']->fetch_the_id();
$GLOBALS['TSFE']->getPageAndRootline();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$GLOBALS['TSFE']->forceTemplateParsing = 1;
$GLOBALS['TSFE']->getConfigArray();
$cObj = t3lib_div::makeInstance('tslib_cObj');
This initializes the TSFE and cObj but is also used to load and parse the TypoScript templates. You might need to make some modifications to (probably kick some things out)
The code came from one of the comments on the following blog post: http://sebastiaandejonge.com/blog/articles/2010/september/21/bringing-ajax-to-your-frontend-plugins/
Good luck!

Running a premade bulletin board through my Front Controller in Zend

I tried to ask this once, but I think that my former question was too unclear for you guys to answer, so I'll try again
I'm making a website using the Zend Framework, and am trying to include the premade messageboard Phorum. So far, I've made it work by not running it through my bootstrap using my .htaccess file. What I'd like to do i'd like to do is to be able to run it through my bootstrap so that I can use my previously created Layouts and Classes that I can only run through Zend.
For example, I have a premade sign in system that works through Zend_Auth. I have the person's data saved in Zend_Session. I load the user's profile through a controller. I have a service layer for the model that connects to my database on behalf of the user. There are several other dependencies that, as far as I can tell, I need the bootstrap for.
Phorum is basically just a large set of PHP scripts that are dependent on GET parameters. My original idea had been to use a controller to render the scripts. An example of what that URI would look like is this: My-Site.com/messageboard/list.php?1,3 with messageboard being the messageboardController. While this works for loading list, it can't capture the GET parameters, which Phorum is dependent on. Due to the complex nature of Phorum, it would be nearly impossible for me to be able to go in and make it something like My-Site.com/messageboard/list/1/3 or anything along those lines. The URI has to be the former, as it is built in to Phorum.
I have tried using frames. I got to keep my log in panel up top, and had the body of the page be a frame, but it was unbookmarkable, and the back button made everything outrageously difficult. I also couldn't get the frame to talk to the parent page in Zend well, so frames aren't an option.
Does anyone have a way that I can do this? What I need, in essence, is to take the script (ex. list.php?1,3) and place whatever it would render, after having used the 1,3 parameters, into a div in the "body" div of my layout. As far as I can tell, render doesn't seem to be able to capture the GET parameters. Does anyone know of a way I can do this.
Any ideas would be immeasurably appreciated. Thank you for your help!
This isn't a trivial thing to process, however, it is possible to write a custom route, along with some controller magic to handle this sort of thing and include the proper php file:
First of all - Your route should probably be (in ZF1.9 application.ini conventions)
resources.router.routes.phorum.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.phorum.route = "messageboard(?:/(.*))?"
resources.router.routes.phorum.defaults.controller = "phorum"
resources.router.routes.phorum.defaults.action = "wrapper"
resources.router.routes.phorum.defaults.module = "default"
resources.router.routes.phorum.defaults.page = "index.php"
resources.router.routes.phorum.map.1 = "page"
Now all requests to messageboard/whatever.php should be routed to PhorumController::wrapperAction() and have 'whatever.php' in $this->getRequest()->getParam('page')
Then it should become a simple matter of redirecting your "wrapper" action to include the proper php file from phorum. I have added some code from a similar controller I have (although mine didn't include php files - it was meant solely for serving a directory of content)
public function wrapperAction() {
$phorumPath = APPLICATION_PATH."../ext/phorum/";
$file = realpath($phorumPath . $this->getRequest()->getParam('page');
if (!$file || !is_file($file)) throw new Exception("File not found");
// disable default viewRenderer - layout should still render at this point
$this->_helper->viewRenderer->setNoRender(true);
// determine extension to determine mime-type
preg_match("#\.([^.]+)$#", $filename, $matches);
switch (strtolower($matches[1]))
{
case "php":
// patch the request over to phorum
include($file);
return; // exit from the rest of the handler, which deals specifically
// with other types of files
case "js":
$this->getResponse()->setHeader('Content-Type', 'text/javascript');
ini_set('html_errors', 0);
break;
case "css":
$this->getResponse()->setHeader('Content-Type', 'text/css');
ini_set('html_errors', 0);
break;
case "html":
$this->getResponse()->setHeader('Content-Type', 'text/html');
break;
// you get the idea... add any others like gif/etc that may be needed
default:
$this->getResponse()->setHeader('Content-Type', 'text/plain');
ini_set('html_errors', 0);
break;
}
// Disable Layout
$this->_helper->layout->disableLayout();
// Sending 304 cache headers if the file hasn't changed can be a bandwidth saver
$mtime = filemtime($fn);
if ($modsince = $this->getRequest()->getServer('HTTP_IF_MODIFIED_SINCE'))
{
$modsince = new Zend_Date($modsince);
$modsince = $modsince->getTimestamp();
if ($mtime <= $modsince) {
$this->getResponse()->setHttpResponseCode(304);
return;
}
}
$this->getResponse()->setHeader('Last-Modified', gmdate("D, d M Y H:i:s",$mtime). " GMT");
readfile($fn);
}
Please - Make sure to test this code for people trying to craft requests with .., etc in the page.