Page 1 of 1

List View - Limit Preview Size of field X

PostPosted: Wed Feb 04, 2009 10:51 am
by nibra2000
Hello,
I am looking for a way to modify the default preview size while in List View.
Really only need this for one field, but it would be ok to apply this sort of property to the entire List View.
Each of my records has a "notes" field which can be several paragraphs long (up to 1024 characters).
Currently while viewing my records in List View, the notes field has a preview that is larger than I would like...distorts the size of row, and also does not print well.

i.e. While in the List View, I want my "notes" field to show a preview of only 256 characters...
Then users can click the record to view the full record.

I've read a couple posts concerning this, but have not found anything conclusive or anybody claiming to have successfully done this yet.
I am using "Dataface 1.0.7 561"

Thank's
-B

PostPosted: Wed Feb 04, 2009 11:29 am
by shannah
Hi,

The list view already truncates text fields at 255 characters by default. The latest version of Xataface (or 1.1.1 or later) allows you to specify the default preview length in the GET parameters:
----
Added support for the --default-preview-length GET parameter which sets the cut
off for TEXT fields when retrieving them for reading.

This is relevant to actions like export_json, or the list view.

E.g. --default-preview-length=2500 will limit text fields to 2500 characters (fo
r reading - doesn't affect writing).

The default value is 255 if it is not specified.

----

Hence you could add the following to the beginning of your index.php file (if you are using 1.1.1 or later), to change the preview length:

Code: Select all
$_GET['--default-preview-length'] = 64


Of course this only applies to text fields (not varchar fields).

-Steve

i upgraded - but now it throws and error

PostPosted: Wed Feb 04, 2009 12:21 pm
by nibra2000
Thank's for the reply,
I tried the suggestions, but it throws an error.
First I upgraded to Dataface 1.1.3 928 - the dataface_info() shows the new verison, and things seem to work correctly.

But when I add the line: ' $_GET['--default-preview-length'] = 64 '- to the top of my index.php, I get the following error:
<begin>
"" Parse error: syntax error, unexpected T_IF in /var/www/servers/index.php on line 14 ""
</end>

I am posting my entire index.php here....

<begin>


<?php
/**
* File: index.php
* Description:
* -------------
*
* This is an entry file for this Dataface Application. To use your application
* simply point your web browser to this file.
*/

/**
$_GET['--default-preview-length'] = 64
**/


/*
*increase search limit
**/

if ( !isset( $_REQUEST['-limit']) ){
$_REQUEST['-limit'] = 255;
$_GET['-limit'] = 255;
}




$time = microtime(true);
// use the timer to time how long it takes to generate a page
require_once '/var/www/xataface/dataface-public-api.php';
// include the initialization file
df_init(__FILE__, '/xataface');
// initialize the site

$app =& Dataface_Application::getInstance();
// get an application instance and perform initialization
$app->display();
// display the application


$time = microtime(true) - $time;
echo "<p>Execution Time: $time</p>";
?>


</end end>

Any tips or advice is much appreciated.
Thank's
-B

PostPosted: Wed Feb 04, 2009 12:23 pm
by shannah
The forum stripped your post. Try reposting but check the "disable HTML in this post" box, so that the forum will leave it alone.

My best guess is that you forgot to put a semi colon at the end of the line (php syntax error).

e.g.

Code: Select all
<?php
$_GET['--default-preview-length'] = 64;

...

PostPosted: Wed Feb 04, 2009 12:28 pm
by shannah
It is also worth noting that you can also customize the way any field is rendered in list view by implementing the %fieldname%__renderCell() method.

http://xataface.com/documentation/how-to/list_tab

still too many characters...

PostPosted: Wed Feb 04, 2009 12:37 pm
by nibra2000
Steve,
thank you for the quick replies - it was sloppy programming on my part, twas the darn missing semi-colon ;
With the semi-colon in place, the page now loads yay!
At top of index.php - I have:' $_GET['--default-preview-length'] = 64; '
But I am still getting 200+ characters loading for my notes field...
So its not being truncated the way i would like.

I will look into the other link you suggested also..

I'll check back for any suggestions.
thank's again !!

-B

PostPosted: Wed Feb 04, 2009 12:45 pm
by shannah
What type of field is your notes field? TEXT or VARCHAR? Can you give the precise SQL definition so I can take a look and see if it is a bug in Xataface.

-Steve

Fied Type

PostPosted: Wed Feb 04, 2009 1:02 pm
by nibra2000
The field type is text.
I am using phpmyadmin to create and manage the database.
and I am sure there is a succinct mysqldump command to grab just what you need, but I don't know what sql to use for that just yet...
So I'll summarize what I have in phpmyadmin....
--Field Type Collation Attributes Null Default Extra Action
--notes text latin1_swedish_ci Yes NULL

PostPosted: Wed Feb 04, 2009 1:10 pm
by shannah
Sorry.. you also need to set this in the $_REQUEST array.

e.g.

Code: Select all
$_GET['--default-preview-length'] = $_REQUEST['--default-preview-length'] = 64;


-Steve

Looks good...this worked...

PostPosted: Wed Feb 04, 2009 1:17 pm
by nibra2000
That did the trick.
$_GET['--default-preview-length'] = $_REQUEST['--default-preview-length'] = 64;
in my index.php limited the Preview to 64 characters in length..

So far, so good.
I'll test it some more and let you know...

-B