4.7. URL linking

Fields can be made 'clickable' in the display using ['URL'] variable. Primary examples follows:

Example 4-30. Simple URL examples

$opts['fdd']['col_name']['URL'] = 'http://$link';  
$opts['fdd']['col_name']['URL'] = 'mailto:$value'; 

Note that the following are available as variables for usage in ['URL']:

  $key -- key field for record
  $name -- name of the field
  $value -- value of the field
  $link -- not modified raw value
  $css -- CSS class name
  $page -- this HTML page
  $url -- CGI variables

To open a link in a new web browser window use:

Example 4-31. URL target example

$opts['fdd']['col_name']['URLtarget'] = '_blank'; 

To display alternative link text use:

Example 4-32. URL display example

$opts['fdd']['col_name']['URLdisp'] = 'Launch Page'; 

Old 3.5 behaviour is also supported via ['URLprefix']. It will prepend string before if it is not already present there. Variable ['URLpostfix'] similary to ['URLprefix'] will append string after if it is not already present there.

Example 4-33. URL prefix and postfix

$opts['fdd']['col_name']['URLprefix'] = 'mailto:';  
$opts['fdd']['col_name']['URLprefix'] = 'http://';  
$opts['fdd']['col_name']['URLprefix'] = array('http://', 'ftp://'); 

In the third example you can see that array of prefixes or postfixes are supported. First member of array is added to URL value only if none from the elements was matched. This is especially useful in having intelligent URL links with added ability to enter addresses like "www.platon.sk" without preceding "http://".

Bootstrap phpMyEdit PHP Form Generator