[Typo3-dev] clean typo-link function

Peter Niederlag pn at kreativwert.de
Tue Sep 30 08:30:05 CEST 2003


Hi Sascha,

Sacha Vorbeck <sachav at gmx.net> schrieb :

I am using the stuff Luite(?) and Joh(?) posted in one of the threads
regarding this topic. It works nicely so far and is pretty much what
Luite told here also.

> Hi Luite,
> 
> > *) what other features / what do you mean by "don't get it to work",
> > I mean: what output do you get then?
> 
> I copied your function into the class.tx_ttproducts.php and now my
> main problem is the product list.
> 
> To create the links to the products with your function I somehow have
> to pass the ID of the detail-view page and the product ID to your
> function:
> 
> $test1 = 
> $this->get_url(testlink,array('id'=>$this->conf['PIDitemDisplay'],'tt
> _products'=>$row['uid']));
> 
> This function call will generate the following link:
> http://euregio-gundogs.com/index.php?id=73&L=0&tx_ttproducts[0]=67&tx_ttproducts[id]=67&tx_ttproducts[tt_products]=43

1)
well since you call it with id=>$this->conf['PIDitemDisplay'] it will
link to the detail page of tt_products. You probably rather want the the
backPID here. Dont know how to get that but it shoukld at least be in
the HTTP_REFERER but looks like it is in tt _products=>$row['uid']
somewhere also.

2)
You have the problem that get_url uses $piVars[$this->prefixId.'[$key']]
which is correct for most modern extensions since they prepare/expect
there piVars in an array myext["var1"], myext["var2"]. But that is not
the case for tt_products! So you need to find the line in your code
which puts that "prefix" in there. Maybe you have to  call get_url not
with ...tt _products=>$row['uid'] but somehow with 'backPid' and
'tt_products'.

Be patient. Everything is there and prepared, it is just not put
together correctly yet.

> but it should be:
> http://euregio-gundogs.com/index.php?id=67&backPID=73&tt_products=43

So basicly you need to modify the name of the vars, values are all
there.

This is what I use, derived/copied from the mailarchive:

function get_url($tag = '', $vars = array(), $unsetVars=array(),
$usePiVars = true, $target = ''){
                //debug($target);
                if(!$target && $this->internal["target"]) {
                        $target = $this->internal["target"];
                        }
                $vars = (array)$vars;
                //debug ($vars);
                $unsetVars = (array)$unsetVars;
                //debug($unsetVars);
                if($usePiVars) {
                        $vars = array_merge($this->piVars, $vars);
//vars override pivars
                        while(list(,$key) = each($unsetVars)){ //
unsetvars override anything
                                unset($vars[$key]);
                        }
                }
                while(list($key,$val) = each($vars)) {
                        $piVars[$this->prefixId . '['. $key . ']'] =
$val;
                }
                if($tag) {
                                return
$this->cObj->getTypoLink($tag,$GLOBALS["TSFE"]->id,$piVars,$target);
                                }
                else {
                                return
$this->cObj->getTypoLink_URL($GLOBALS["TSFE"]->id,$piVars,$target);
                                }
                        }
        }

hth,
PeterN

P.S.: Maybe put up your get_url function somewhere so we can have a look
at it, or are you calling ->getTypoLink straight away?
-- 
Peter Niederlag
http://www.ikd01.de * Information Kommunikation Design *
http://www.clown-goli.de * Clown-Comedy-Jonglage-Animation *






More information about the TYPO3-dev mailing list