Discussion:
[Typo3] pass 2 values from 10.data to userfunc
Carlos Rodriguez
2005-07-27 05:56:59 UTC
Permalink
Hi all,

I have the following code:

includeLibs.abc = fileadmin/includes/class.user_abc.php

lib.abc = COA
lib.abc {
10 = USER
10.userFunc = user_linkmarker->main
10.data= field:field_listtext,field:field_url
}

When I look at my page the value of 10.data is
"field:field_listtext,field:field_url" NOT the values of this fields.

What do I miss? Whats the prob?

Even when I try "10.data= field:field_listtext" instead the problem is,
that NOT the value of "field:field_listtext" is passed but only the
string "field:field_listtext" is passed. Why?

What do I miss? Whats the prob?

Tahnks
Nyeki Attila
2005-07-27 06:13:53 UTC
Permalink
Post by Carlos Rodriguez
Hi all,
includeLibs.abc = fileadmin/includes/class.user_abc.php
lib.abc = COA
lib.abc {
10 = USER
10.userFunc = user_linkmarker->main
10.data= field:field_listtext,field:field_url
10.insertData = 1
Post by Carlos Rodriguez
}
this should do
Post by Carlos Rodriguez
When I look at my page the value of 10.data is
"field:field_listtext,field:field_url" NOT the values of this fields.
What do I miss? Whats the prob?
Even when I try "10.data= field:field_listtext" instead the problem is,
that NOT the value of "field:field_listtext" is passed but only the
string "field:field_listtext" is passed. Why?
What do I miss? Whats the prob?
Tahnks
Attila
Nyeki Attila
2005-07-27 06:18:34 UTC
Permalink
it's me again

use { brackets

{field:field_listtext}

i'm not 100% sure but I thing they are required
Post by Nyeki Attila
Post by Carlos Rodriguez
Hi all,
includeLibs.abc = fileadmin/includes/class.user_abc.php
lib.abc = COA
lib.abc {
10 = USER
10.userFunc = user_linkmarker->main
10.data= field:field_listtext,field:field_url
10.insertData = 1
Post by Carlos Rodriguez
}
this should do
Post by Carlos Rodriguez
When I look at my page the value of 10.data is
"field:field_listtext,field:field_url" NOT the values of this fields.
What do I miss? Whats the prob?
Even when I try "10.data= field:field_listtext" instead the problem
is, that NOT the value of "field:field_listtext" is passed but only
the string "field:field_listtext" is passed. Why?
What do I miss? Whats the prob?
Tahnks
Attila
Carlos Rodriguez
2005-07-27 06:31:58 UTC
Permalink
Post by Nyeki Attila
use { brackets
{field:field_listtext}
i'm not 100% sure but I thing they are required
Post by Nyeki Attila
Attila
Thats my complete code now...

includeLibs.linkmarker= fileadmin/includes/class.user_linkmarker.php

lib.linkmarker= COA
lib.linkmarker {
10 = USER
10 {
userFunc = user_linkmarker->main
data = {field:field_listtext}
insertData = 1
}


The stuff with the brackets - yeah - thats what I found in some
tutorial, but even with brackets and insert Data ist still does not work.

grrr this drives me crazy...
=)

Yes, I checked the field name of "listtext" in the DS, its alsso running
into the main function...I also cleares both(!) caches and the
temp_Cached under typo3conf

I am at a loss...

:-(
Nyeki Attila
2005-07-27 06:58:48 UTC
Permalink
I just noticed that this is all about a userFunc.
I've always used this "insertData" thing in content/page rendering, not
in parameters for user functions.

But I have an idea, try this:

temp.x = TEXT
temp.x.value = {field:field_listtext}
temp.x.insertData = 1

and then:

10 = USER
10 {
userFunc = user_linkmarker->main
data < temp.x
}

I'm not sure that this is the right way in Typo3 but it could work.

I also found an example in Modern Template Building, Part 1 documentation:

First, lets create a PHP-file in fileadmin/userfunctions.php:
<?php

class user_functions {

/**
* Multiplies the current page ID with $conf["factor"]
*/
function multiplyTest($content,$conf) {
$currentPageUid = $GLOBALS['TSFE']->id;
$factor = intval($conf['factor']);

return $currentPageUid * $factor;
}
}
?>

Then lets configure a cObject of the type USER to call this function
with a single parameter, "factor":
# Default PAGE object:
page = PAGE
page.typeNum = 0
page.includeLibs.some_random_id_string = fileadmin/userfunctions.php
page.config.admPanel = 1

# Content object outputting current page title:
page.10 = HTML
page.10.value = The page ID, {field:uid}, multiplied with 15 is:
page.10.value.insertData = 1
page.10.value.wrap = <b> |</b> <br />

page.20 = USER
page.20.userFunc = user_functions->multiplyTest
page.20.factor = 15
Post by Carlos Rodriguez
Post by Nyeki Attila
use { brackets
{field:field_listtext}
i'm not 100% sure but I thing they are required
Post by Nyeki Attila
Attila
Thats my complete code now...
includeLibs.linkmarker= fileadmin/includes/class.user_linkmarker.php
lib.linkmarker= COA
lib.linkmarker {
10 = USER
10 {
userFunc = user_linkmarker->main
data = {field:field_listtext}
insertData = 1
}
The stuff with the brackets - yeah - thats what I found in some
tutorial, but even with brackets and insert Data ist still does not work.
grrr this drives me crazy...
=)
Yes, I checked the field name of "listtext" in the DS, its alsso running
into the main function...I also cleares both(!) caches and the
temp_Cached under typo3conf
I am at a loss...
:-(
Dmitry Dulepov
2005-07-28 05:03:06 UTC
Permalink
Hi!

Actually I was interested in this problem too and I tried this approach
yeasterday. It does not work. :( It seems that userFunc is execute
*before* all "insertData" is processed. $conf will contain the values as
specified in TS.

Dmitry.
Post by Nyeki Attila
I just noticed that this is all about a userFunc.
I've always used this "insertData" thing in content/page rendering, not
in parameters for user functions.
temp.x = TEXT
temp.x.value = {field:field_listtext}
temp.x.insertData = 1
10 = USER
10 {
userFunc = user_linkmarker->main
data < temp.x
}
I'm not sure that this is the right way in Typo3 but it could work.
<?php
class user_functions {
/**
* Multiplies the current page ID with $conf["factor"]
*/
function multiplyTest($content,$conf) {
$currentPageUid = $GLOBALS['TSFE']->id;
$factor = intval($conf['factor']);
return $currentPageUid * $factor;
}
}
?>
Then lets configure a cObject of the type USER to call this function
page = PAGE
page.typeNum = 0
page.includeLibs.some_random_id_string = fileadmin/userfunctions.php
page.config.admPanel = 1
page.10 = HTML
page.10.value.insertData = 1
page.10.value.wrap = <b> |</b> <br />
page.20 = USER
page.20.userFunc = user_functions->multiplyTest
page.20.factor = 15
Post by Carlos Rodriguez
Post by Nyeki Attila
use { brackets
{field:field_listtext}
i'm not 100% sure but I thing they are required
Post by Nyeki Attila
Attila
Thats my complete code now...
includeLibs.linkmarker= fileadmin/includes/class.user_linkmarker.php
lib.linkmarker= COA
lib.linkmarker {
10 = USER
10 {
userFunc = user_linkmarker->main
data = {field:field_listtext}
insertData = 1
}
The stuff with the brackets - yeah - thats what I found in some
tutorial, but even with brackets and insert Data ist still does not work.
grrr this drives me crazy...
=)
Yes, I checked the field name of "listtext" in the DS, its alsso
running into the main function...I also cleares both(!) caches and the
temp_Cached under typo3conf
I am at a loss...
:-(
Tyler Kraft
2005-07-28 08:26:01 UTC
Permalink
Hi

I'm not sure what your trying to do with your php class but a two things
to look at:


1) try the file with a .inc extension not a .php extension (see TSref ->
php_script)?

2) what about stdwrap option of postUserFunc?


As there is no std wrap for the USER maybe try to create as a COA and
manipulte it in your script


includeLibs.abc = fileadmin/includes/class.user_abc.inc

lib.linkmarker= COA
lib.linkmarker {
10.1 = HTML
10.1{
value = {field:field_listtext}
insertData = 1
wrap= |,
}
10.2 = HTML
10.2{
value = {field:field_url}
insertData = 1
}
10.postUserFunc=user_linkmarker->main
}


I think that might then pass into your script two values from fields as
a comma seperated list. Its all justa guess so let us know if it works.

hth
Tyler
Post by Carlos Rodriguez
Hi all,
includeLibs.abc = fileadmin/includes/class.user_abc.php
lib.abc = COA
lib.abc {
10 = USER
10.userFunc = user_linkmarker->main
10.data= field:field_listtext,field:field_url
}
When I look at my page the value of 10.data is
"field:field_listtext,field:field_url" NOT the values of this fields.
What do I miss? Whats the prob?
Even when I try "10.data= field:field_listtext" instead the problem is,
that NOT the value of "field:field_listtext" is passed but only the
string "field:field_listtext" is passed. Why?
What do I miss? Whats the prob?
Tahnks
Tyler Kraft
2005-07-28 18:04:13 UTC
Permalink
any one try this yet? I'm curious if it worked?
Post by Tyler Kraft
Hi
I'm not sure what your trying to do with your php class but a two things
1) try the file with a .inc extension not a .php extension (see TSref ->
php_script)?
2) what about stdwrap option of postUserFunc?
As there is no std wrap for the USER maybe try to create as a COA and
manipulte it in your script
includeLibs.abc = fileadmin/includes/class.user_abc.inc
lib.linkmarker= COA
lib.linkmarker {
10.1 = HTML
10.1{
value = {field:field_listtext}
insertData = 1
wrap= |,
}
10.2 = HTML
10.2{
value = {field:field_url}
insertData = 1
}
10.postUserFunc=user_linkmarker->main
}
I think that might then pass into your script two values from fields as
a comma seperated list. Its all justa guess so let us know if it works.
hth
Tyler
Post by Carlos Rodriguez
Hi all,
includeLibs.abc = fileadmin/includes/class.user_abc.php
lib.abc = COA
lib.abc {
10 = USER
10.userFunc = user_linkmarker->main
10.data= field:field_listtext,field:field_url
}
When I look at my page the value of 10.data is
"field:field_listtext,field:field_url" NOT the values of this fields.
What do I miss? Whats the prob?
Even when I try "10.data= field:field_listtext" instead the problem
is, that NOT the value of "field:field_listtext" is passed but only
the string "field:field_listtext" is passed. Why?
What do I miss? Whats the prob?
Tahnks
Loading...