Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 11. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Create a URL based on multiple fields - How?

phpMyEdit Configuration     Create a URL based on multiple fields - How?
Odoslať novú tému   Odpovedať na tému    
 
thefeldkircher     Založený: 11.10.2008   Príspevky: 9  
Príspevok Zaslal: 2008-10-21 14:14
Návrat hore  Odpovedať s citátom     

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...

 
ajh     Založený: 17.12.2003   Príspevky: 236  
Príspevok Zaslal: 2008-10-22 08:07
Návrat hore  Odpovedať s citátom     

Create a virtual field using the 'sql' option to concatenate the two fields, and use that to generate your URL.

 
thefeldkircher     Založený: 11.10.2008   Príspevky: 9  
Príspevok Zaslal: 2008-10-22 17:05
Návrat hore  Odpovedať s citátom     

ajh Napísal:
Create a virtual field using the 'sql' option to concatenate the two fields, and use that to generate your URL.


Hi thanks for your quick reply, I'm completely new to this can you give me an example.

Your help is much appreciated.

Thanks

 
thefeldkircher     Založený: 11.10.2008   Príspevky: 9  
Príspevok Zaslal: 2008-10-31 00:29
Návrat hore  Odpovedať s citátom     

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

 
paul_mac     Založený: 19.12.2008   Príspevky: 1  
Príspevok Zaslal: 2008-12-19 12:57
Návrat hore  Odpovedať s citátom     

Have you found this posting:

http://opensource.platon.sk/forum/projects/viewtopic.php?t=586

I think it will do what you need. I've used it and it works fine

Regards

Paul

 
thefeldkircher     Založený: 11.10.2008   Príspevky: 9  
Príspevok Zaslal: 2008-12-19 16:02
Návrat hore  Odpovedať s citátom     

Clearly not, if I had it would saved me re-inventing the wheel.

Oh well, onwards and upwards.

 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov