Hi All
I wish to create a url from these two fields
| Kód: |
$opts['fdd']['Name'] = array(
'name' => 'Firma Name',
'select' => 'T',
'maxlen' => 40,
'sort' => true
);
$opts['fdd']['BoxType'] = array(
'name' => 'Box Type',
'select' => 'D',
'maxlen' => 10,
'URL' => '$value.php?target=$key&fn='. (value of Firma Name) ,
'URLtarget' => '_blank',
'values' => array(
'table' => 'boxtype',
'column' => 'BoxId',
'description' => 'Type'
),
'sort' => true
);
|
| Kód: |
$value.php?target=$key - works perfectly |
I just need to append the $value of 'Firma Name'.
Any Ideas?, I'm getting no where
Thanks for any help...
|
| thefeldkircher Napísal: |
Hi All
I wish to create a url from these two fields
| Kód: |
$opts['fdd']['Name'] = array(
'name' => 'Firma Name',
'select' => 'T',
'maxlen' => 40,
'sort' => true
);
$opts['fdd']['BoxType'] = array(
'name' => 'Box Type',
'select' => 'D',
'maxlen' => 10,
'URL' => '$value.php?target=$key&fn='. (value of Firma Name) ,
'URLtarget' => '_blank',
'values' => array(
'table' => 'boxtype',
'column' => 'BoxId',
'description' => 'Type'
),
'sort' => true
);
|
| Kód: |
$value.php?target=$key - works perfectly |
I just need to append the $value of 'Firma Name'.
Any Ideas?, I'm getting no where
Thanks for any help... |
After hacking together various CONCAT functions, pulling my hair out and basically dicking around, I decided to find my own solution and I thought I would share it with you.
My original wish was to be able to have two value pairs sent with the URL
$key and $fn, $fn would be the $value of Firma Name
Well in fact with this method you can append any second field value to the URL, provided your primary URL ends with &blahblah=
This method ONLY allows TWO fields to be added together, but I am sure some of you experts out there can extend this further.
Now this is not official and I don't give any guarantees this will work for every situation,
but this is my class hack to append a second field value on the end of the URL.
Firstly I am using
| Kód: |
| /* $Platon: phpMyEdit/phpMyEdit.class.php,v 1.211 2008-06-04 10:49:39 michal Exp $ */ |
And I added the $row reference to the
urlDisplay
function
| Kód: |
| function urlDisplay($k, $link_val, $disp_val, $css, $key, $row) /* {{{ */ //Added $row reference for URL Hack |
In the same function I added between the $page and $url vars
| Kód: |
$page = $this->page_name;
// 27/10/08: TheFeldkircher // hack to add Second Field $Value to URL
for ($f = 1; $f < $this->num_fds; $f++) { // 0 = PK So ignore it
if($this->fdd[$f]['urlAdd']){ // If field Array has urlAdd => true then use this fields value
$urlAdd = $row["qf$f"]; // Extract field $value and set it to var $urlAdd
}
}
$url = $this->cgi['prefix']['sys'].'rec'.'='.$key.'&'.$this->cgi['prefix']['sys'].'fm' |
Now just before the end of this function I added the $urlAdd variable to this functions $ret variable - like so
| Kód: |
| $ret = '<a '.$target.'class="'.$css.'" href="'.$urllink.$urlAdd.'">'.$urldisp.'</a>'; // Add Second field value here - if $urlAdd is empty then its ignored |
Fortunately the next function
cellDisplay
is the one we need to change slightly - scroll down until you find -
| Kód: |
if ($this->col_has_URL($k)) {
return $this->urlDisplay($k, $original_value, $value, $css, $key_rec, $row); // Added $row reference for URL Hack
} |
and add the $row reference to the function call.
And that's it for the Class - so save it.
Going back to my original post - all I have to do now is add -
| Kód: |
$opts['fdd']['Name'] = array(
'name' => 'Firma Name',
'select' => 'T',
'maxlen' => 40,
'urlAdd' => true, // My New Array value
'sort' => true
);
|
And were good to go, now I get a URL with two fields
| Kód: |
| http://localhost/healthy.php?target=6&fn=Someone |
and no messy escape-ing or Concat hell.
Hope you find it useful
|