This topic is locked

Conditional Master detail

7/13/2006 8:13:04 AM
PHPRunner General questions
kujox author

Hi
Is there a way to only display the master-detail link if a condition is true?
I only want to display the link if say field1=0, would the code need to go in the listpage on load event.
or is this something that I would have to code in after the project is finished?
Thanks
Chris

J
Jane 7/13/2006

Chris,
to remove detail link if a condition is true you need to modify looprs($rsData,$nPageSize) function in the generated ..._list.php file.

kujox author 7/13/2006

Jane
Thanks, I'll have to do that once the project is complete

I
itxlieni 1/10/2007

Hi
I found this part in my ....list.php file
for($col=1;$data && $recno<=$PageSize && $col<=1;$col++)
What i have to do to show the Link only if ther are some data?
Thanks

J
Jane 1/10/2007

Hi,
you can do it editing generated files manually:

  1. open templates/..._list.htm file, find this line:
    <a href="DetailTableName_list.php?{$row.1DetailTableName_masterkeys}">DetailTableName</a>

and replace it with this one:

{if $row.1DetailTableName_masterkeys!=""}

<a href="DetailTableName_list.php?{$row.1DetailTableName_masterkeys}">DetailTableName</a>

{/if}


2. then open ..._list.php file, fine following code:

$row[$col."DetailTableName_masterkeys"]=$masterquery;



and replace it with this one:

$str = "select * from `DetailTableName` where `FieldName`=".$row[$col."id1"];

$rs1 = db_query($str,$conn);

if ($data1 = db_fetch_array($rs1))

$row[$col."DetailTableName_masterkeys"]=$masterquery;

else

$row[$col."DetailTableName_masterkeys"]="";



where DetailTableName is your actual table name, FieldName is your actual field name in the detail table where foreign key is stored.