Record title (how to display multiple fields?)

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

Record title (how to display multiple fields?)

Postby kokoro » Sat Mar 07, 2009 6:53 pm

Steve, & All,

I know I said I would try to avoid asking elementary questions but since my skill level is low it seems I can't avoid it :oops:

I checked my PHP & MySQL reference books but had no luck.

Steve provided the following code to enable multiple fields to be displayed in the jump menu

class tables_mdl_user {
function getTitle(&$record){
return $record->display('username');
}

function titleColumn(){
return 'CONCAT(firstname," ",lastname)';
} }

and it works perfectly. I thought I'd be greedy and try to display the record name as 'firstname' , 'lastname' as follows:

class tables_mdl_user {
function getTitle(&$record){
return $record->display 'CONCAT(firstname," ",lastname)';
}

function titleColumn(){
return 'CONCAT(firstname," ",lastname)';
} }

But had no luck.

Also, (not directly related but) I noticed that in my production site, with 3367 records in a table, the jump menu does not appear at all...?

Jason
kokoro
 
Posts: 39
Joined: Fri Feb 06, 2009 6:17 am

Record title (how to display multiple fields?)

Postby rdb » Sat Mar 07, 2009 7:16 pm

Try

class tables_mdl_user {
function getTitle(&$record){
return $record->display('firstname') . " " . $record->display('lastname)';
}
- -
rdb
rdb
 
Posts: 10
Joined: Wed Feb 25, 2009 10:17 am
Location: Burnaby, BC

Postby kokoro » Sat Mar 07, 2009 9:31 pm

rdb,

Thanks! That did it. Just curious, as I am trying to learn as much as possible as I go, is the code you provided a convention of PHP? I mean the method you provided for displaying multiple records with a space in between them. I definitely need to study it (PHP) more because 'picking it up as I go' is pretty rough.

Jason
kokoro
 
Posts: 39
Joined: Fri Feb 06, 2009 6:17 am

Postby rdb » Sun Mar 08, 2009 8:49 am

Hi Jason,

Let me preface my comments by saying that I'm a newbie with XF and still moderately green with PHP. I've written programs for many years, but mostly in C/C++. That helps, but there is still lots to learn about PHP. That's my disclaimer anyways.

Knowing PHP will help a lot. However I just tested the display() function and found that it needed to be given a field name; it didn't work being handed an expression. So, to get the job done that you want (multiple strings concatenated together), your function has to build that string itself using multiple calls to the display() function. The period (.) is a PHP string concatenation operator.

I would strongly recommend spending some time getting to know both PHP and MySQL. They are heavily used in the web site and web application development world. If you plan on continuing to do work in the web-based field, you'll run into these tools often and it will pay off in spades if you get to know them well.

Have fun!

Cheers.
- -
rdb
rdb
 
Posts: 10
Joined: Wed Feb 25, 2009 10:17 am
Location: Burnaby, BC


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 13 guests

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