[TYPO3] How to add php code into a page?

Stephen Bungert s.bungert at metrinomics.de
Fri May 30 14:32:05 CEST 2008


Isn't there already an extension for adding php content? 

http://typo3.org/extensions/repository/view/lumophpinclude/1.1.0/



-----Ursprüngliche Nachricht-----
Von: typo3-english-bounces at lists.netfielders.de
[mailto:typo3-english-bounces at lists.netfielders.de] Im Auftrag von Dmitry
Dulepov [typo3]
Gesendet: Freitag, 30. Mai 2008 13:04
An: typo3-english at lists.netfielders.de
Betreff: Re: [TYPO3] How to add php code into a page?

Hi!

Ronald Wiplinger wrote:
> I would like to add these lines into a page:
> 
> <?php
> $dday = mktime(0, 0, 0, 3, 29, 2001);
> $diff = time() -$dday;
> $days = $diff / 86400;
> printf( "(%d day%s young)", $days, $days == 1 ? "" :"s"); ?>
> 
> It is just a calculation of days between today and March 29, 2001.
> 
> I added above code into a pagecontent of type HTML.
> 
> What would be the correct way?

If you can include it from TypoScript, the correct way is to create a PHP
file named user_datediff.php with the following content:

<?php

function user_datediff() {
	$dday = mktime(0, 0, 0, 3, 29, 2001);
	$diff = time() - $dday;
	$days = $diff / 86400;
	return sprintf('(%d day%s young)', $days, $days == 1 ? '' : 's');
}

?>

The in TypoScript:

includeLibs.user_datediff = fileadmin/user_datediff.php
page.100 = USER
page.100.userFunc = user_datediff

If you want to use it as content element, you have to make a TYPO3
extension.

-- 
Dmitry Dulepov
TYPO3 core team
Learn more about TYPO3! Read http://typo3bloke.net/
Skype: callto:liels_bugs but go straight to business!
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.netfielders.de
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-english



More information about the TYPO3-english mailing list