need some php syntax help with my delegate class...

A place for users and developers of the Xataface to discuss and receive support.

need some php syntax help with my delegate class...

Postby madmax » Mon Feb 01, 2010 10:30 am

So I have finally manage to wrap my head around a delegate class which allows me to have linkable URL's in one of my columns. it works great, except I cant seem to work out 2 problems. One the URL's need to open in a new window, and not effect the current window. The 2nd problem is a PHP syntax issue. I need to test for 2 conditions, and if either is found, then do not make the field a link. Here's my code:
Code: Select all
<?php
  class tables_master {
  function remote__renderCell( &$record ){
  if (substr($record->strval('remote'),0,3) == "sc0") {
    return $record->strval('remote');
  } else {
    return '<a href=http://'.$record->strval('remote').'>'.$record->strval('remote').'</a>';
  }
}

  function remote__htmlValue( &$record ){
  if (substr($record->strval('remote'),0,3) == "sc0") {
    return $record->strval('remote');
  } else {
      return '<a href=http://'.$record->strval('remote').'>'.$record->strval('remote').'</a>';
  }
}
}
?>



In both functions, I test for strings beginning with "sc0" and if found, then just return the string with no link. I need to modify that so it check for 2 strings, "sc0" and "fj" I cant seem to get the php syntax correct. Does php support something like:

if (condition1 or condition2) then
do nifty stuff here...
endif

So if you guys can help me with the syntax changes, it would be really appreciated!!!!
thanks!
madmax
 
Posts: 7
Joined: Wed Jan 20, 2010 9:00 am

Re: need some php syntax help with my delegate class...

Postby madmax » Mon Feb 01, 2010 10:43 am

ok, I solved the 2 condition problem with the following code, but I still need to modify the URL link to open a new page.

Code: Select all
<?php
  class tables_master {
  function remote__renderCell( &$record ){
     if (substr($record->strval('remote'),0,3) == "sc0") {
         return $record->strval('remote');
     } elseif (substr($record->strval('remote'),0,2) == "fj") {
         return $record->strval('remote');
     } else {
         return '<a href=http://'.$record->strval('remote').'>'.$record->strval('remote').'</a>';
     }
  }


  function remote__htmlValue( &$record ){
     if (substr($record->strval('remote'),0,3) == "sc0") {
         return $record->strval('remote');
     } elseif (substr($record->strval('remote'),0,2) == "fj") {
         return $record->strval('remote');
     } else {
         return '<a href=http://'.$record->strval('remote').'>'.$record->strval('remote').'</a>';
     }
  }
}
?>
madmax
 
Posts: 7
Joined: Wed Jan 20, 2010 9:00 am

Re: need some php syntax help with my delegate class...

Postby madmax » Mon Feb 01, 2010 12:06 pm

finally!! I figured it out, and here's the change to have new page links;

Code: Select all
return '<a href='.$record->strval('remote').' target=\"_blank\">'.$record->strval('remote').'</a>';



it was a space after the ' and before the work target that was killing me!
madmax
 
Posts: 7
Joined: Wed Jan 20, 2010 9:00 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 10 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved