I have created a custom search based on relationships.
Each row shows a contact and a related organisation in separate columns as well as other info.
Each contact is automatically linked to the view page in the search results but I would like the organisation to also be linked. I return a column aliased to "org_id" in the all
function select piece.
, tempTable.org_id
, tempTable.organization_name
I have not added org_id
to my columns array in the constructor because I do not want it to display. If I do then the template file works but I have an extra column.
I have sucessfully overridden the template file as follows:
{if $fName eq 'sort_name'}
<td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`&key=`$qfKey`&context=custom"}">{$row.sort_name}</a></td>
{elseif $fName eq 'organization_name'}
<td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.org_id`&key=`$qfKey`&context=custom"}">{$row.organization_name}</a></td>
{else}
<td>{$row.$fName}</td>
{/if}
It does display a link on the organisation name cell. However the template is not seeing the org_id
value and the link stops at cid=
EG. civicrm/contact/view?reset=1&cid=&key=fb7ffdb351588d7d7d9df84f3b3e03f5_1119&context=custom
Edit: I have also tried this without the template override and used alterRow. This also only works if the org_id
result column is added to the columns list of the custom search.
function alterRow( &$row ) {
$url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$row['org_id']}");
$row['organization_name'] = "<a href=\"{$url}\">{$row['organization_name']}</a>";
}