Page 1 of 1

renderCell help [SOLVED]

PostPosted: Fri Mar 05, 2010 4:01 am
by cantlep
Hi All,

This is my first post. I've been having a look around the forum and it seems like a great community. On that note, I'm hoping someone might be able to help me.

As per this forum post - viewtopic.php?t=4091&highlight= I'm trying to do something similar.

I have a "Customers" table and a "SiteData" table.
In "Customers" one of the fields is "CompanyName", in "SiteData", CompanyName is pulled from the "Customers" table so that I can link sites to customers. (This all works fine).

What i'd like to do is...In the "Customers" table, click on one of the CompanyName links and have it display me all sites from the "SiteData" table that that particular CompanyName is assigned to.

I have this, but it doesn't seem to work.

in tables/Customers/customers.php

Code: Select all
<?php
function CompanyName__renderCell(&$record){
        return '<a href="'.DATAFACE_SITE_HREF.'?-table=SiteData&CompanyName='.$record->val('CompanyName').'">'.$record->val('CompanyName').'</a>';
}
?>


and in tables/Customers/fields.ini

Code: Select all
[CompanyName]
noLinkFromListView=1


When I have noLinkFromListView set, it just doesn't make it a hyperlink (which I guess makes sense) but I want it to make the link that i've specified above. If I don't have it set in fields.ini then it just points to the usual view that the rest of the fields point to (i.e. Usual functionality).

Can anyone help? Have I missed something stupid? Could I possibly ask anymore questions? ;-)

Thanks a lot.

Paul

Re: renderCell help

PostPosted: Fri Mar 05, 2010 6:44 am
by cantlep
Hi All,

I've had a bit of a breakthrough. It seems I was missing the following snippet in my php file

Code: Select all
class tables_Customers {
}


So now the link actually exists. However, the desination isn't really working (and I know why - coz it doesn't exist ;-) )

Here's what I have
Code: Select all
return '<a href="index.php?-action=list&-table=SiteData&CompanyName='.$record->strval('CompanyName').'">'.$record->val('CompanyName').'</a>';


What I want the output to show is the same as when I use the "find" functionality and select "Only show me Company blah" In this instance, the URL looks like this
Code: Select all
http://mysite/index.php?-action=list&-table=SiteData&-cursor=0&-skip=0&-limit=30&-mode=find&-recordid=SiteData%3FSiteDataIDM7&CompanyName=%3D2


Do I literally have to type that into the php file (substituting the necessary words for the $record variable)?

Thanks

Paul

Re: renderCell help

PostPosted: Fri Mar 05, 2010 7:09 am
by cantlep
and....All sorted :-)

Code: Select all
return '<a href="index.php?-action=list&-table=SiteData&-limit=30&-mode=find&CompanyName='.$record->strval('BusinessID').'">'.$record->val('CompanyName').'</a>';


It was the BusinessID bit that sorted it. The URL wasn't found due to not being able to tie up the ID with the CompanyName.

I realise it's working but is this the best way to do it?

Thanks

Paul