Zen TYPO3 Forum

Our TYPO3 forum is available for freelancers, professionals and clients new to TYPO3 to discuss Basic TYPO3 templating, Typoscript, extension installation, administration and help with subscription templates. Please register for an account to post.

All Categories > TYPO3 General Discussion > Templates > Inserting php in html template
Total Posts: 3 - Pages (1): [1]
Author: cris82
Posted: Sep 27 2007 - 01:29 PM
Subject: re: Inserting php in html template
If you had well undestanded your typoScript the steps to include an PHP script in your template are short.

For instance, let assume that you have defined a subpart ###script### in your template, like this

...
<body>
<!-- ###DOCUMENT_BODY### -->

<!-- ###content### content here-->

<!-- ###content### -->

<!-- ###script### script here-->

<!-- ###script### -->
<!-- ###DOCUMENT_BODY### -->
</body>
...

you could include in your TS these codes to integrate your php script (in your user_my_script.php file):

includeLibs.my_php_script = fileadmin/user_my_script.php
#...
workOnSubpart = DOCUMENT_BODY
subparts.content < styles.content.get
subparts.script = USER_INT
subparts.script.userFunc = your_php_class_name->your_php_function_name

for more details just read at this :
http://wiki.typo3.org/index.php/Introduction/Matthew



ok this could works, but I'm a newbie too , I do it, but my php script is rendered in top of my template (before the <HTML> tag) instead of the template's position defined by ##script## subpart:

Someone know the cause of this? maybe is cause my function try to put on screen html code by echo?
Author: mediatech
Posted: Jun 20 2007 - 04:53 PM
Subject: re: Inserting php in html template
I recommend looking at one of the free templates here before committing to the automaketemplate extension. I've never needed it for some reason.

I'm no programmer. Unless someone here can come up with a definitive answer sooner than later you'll probably need to do some digging at http://support.typo3.org

Did you have a look at the PHP include scripts docs? Interesting how there are 2.

PHP include scripts
PHP include-scripts

Gregory Remington
Mediatech Consulting, Inc.
Phone : +1 (760) 525-1770 . Fax: +1 (760) 542-1990 . Skype: gremington

Author: leemchildress
Posted: Jun 20 2007 - 03:48 PM
Subject: Inserting php in html template
I'm a newbie, but I'm slowly getting a grasp on this.

My goal is to display php data within an html result. For example, let's say I want to include today's date on the front page. (I know typo3 has its own date function, but lets use php as a learning experience for me).

My html template has <div id="today">Today's Date</div>

Following is my TypoScript:

# CONFIGURING THE AUTO-PARSER
plugin.tx_automaketemplate_pi1 {
content = FILE
content.file = fileadmin/templates/master_template.html
elements {
BODY.all = 1
HEAD.all = 1
DIV = 1
TD.all = 1
}
relPathPrefix = fileadmin/templates/
}

# HEAD TEMPLATE cOBJECT
temp.Head = TEMPLATE
temp.Head {
template =< plugin.tx_automaketemplate_pi1
workOnSubpart = DOCUMENT_HEADER
}

# MAIN TEMPLATE cOBJECT
temp.mainTemplate = TEMPLATE
temp.mainTemplate {
template =< plugin.tx_automaketemplate_pi1
workOnSubpart = DOCUMENT_BODY
}

# DEFAULT PAGE SETUP
page = PAGE
page.typeNum = 0
page.config.admPanel = 1
page.10 < temp.mainTemplate
page.headerData.10 < temp.Head

Let's say I have a php script called "today.inc" located in fileadmin/includes and I need to pass it a parameter giving the format of the returned date. Let's say the call for this function is today("F d, Y")

How do I call that function and replace <div id="today"></div> with that info?
Total Posts: 3 - Pages (1): [1]
You must login to post a message to this conference.

 

CHC Forum provided by Cast Iron Coding

TYPO3 Support