This topic is locked

Custom "View As" to output field as URL

5/18/2012 3:10:33 PM
PHPRunner General questions
mcebula author

Trying to add a field to export which is the key field value formatted as URL to the view page of the item. So people can export large amount of items and be able to copy links and paste into Word docs.
Added a field to SQL page, ASSUMPTION_ID AS LINK (assumption_id is the key field column)

Added "Link" field only to export in Fields page.

Had to drop the field somewhere in editor to work on it so added it to export choice page (doesn't show up in output which is good because just want it in export itself)
Tried 2 things in "View as" on the link field...

  1. tried formatting as hyperlink (various ways)...none seem to output into Word as URL (just the key value text).
  2. tried as custom field which I can get to work but I had to hard-code the server value at front of URL. Is there some variable I can use instead so value changes between local and production server? If not I'll just use production server.
    Here is code snipper for custom field so you can see the hard-coded http...

$value = "<a href=\"http://localhost/bdrlocal/ASSUMPTION_view.php?editid1=".rawurlencode($data["ASSUMPTION_ID"])."\">".$data["ASSUMPTION_ID"]."<a/>";;
Sergey Kornilov admin 5/18/2012

There us no need to use server address at all. Instead of http://localhost/bdrlocal/ASSUMPTION_view.php you can simply use /bdrlocal/ASSUMPTION_view.php

mcebula author 5/21/2012

Leaving off server prefix works in UI but for some reason works differently in export. I keep getting some kind of "file///" prefix inserted before - example file///c:\bdrlocal\.
Works fine if I hard-code the server so guess I'll just use the production server address.

Sergey Kornilov admin 5/21/2012

Check system variable $_SERVER['SERVER_NAME'].
More info at http://php.net/manual/en/reserved.variables.server.php