Cut cell at certain character limit in results view

drashrafsabry

Well-known member
i assume i covered all scenarios here?

function dadabik_truncate($value)
{

if ($GLOBALS['function'] === 'edit' && isset($GLOBALS['is_items_table']) && $GLOBALS['is_items_table'] === 1 && strlen_custom($value) > 150){
return nl2br(substr_custom($value, 0, 150).'<b>......</b>'); }

elseif ($GLOBALS['function'] === 'details' && isset($GLOBALS['is_items_table']) && $GLOBALS['is_items_table'] === 1 && strlen_custom($value) > 150){
return nl2br(substr_custom($value, 0, 150).'<b>......</b>'); }


elseif ($GLOBALS['function'] === 'search' && strlen_custom($value) > 150){
return nl2br(substr_custom($value, 0, 150).'<b>......</b>'); }


else
{
return nl2br($value);
}


}
 

eugenio

Administrator
Staff member
Yes, with the first statement you are also covering the results grid in an edit page.
 

the_engineer

New member
Hi,

I am also trying to implement this very function to truncate the results in the Search form.
I see that the function can be added to the 'custom_functions.php'.

I am having a hard time figuring out where to modify existing code to call this function. Is it in the header.php file?
 

eugenio

Administrator
Staff member
Hello,
no, you don't have to modify any code, you have to declare the function as custom formatting function for the relevant field in form configurator.

Best,
 

Mbeauc636

New member
Hi.

I am using dadabik 9.2.1 / php ver 7.0.32-0, mysql 5.7.24

I have added the dadabik_truncate function posted by drashrafsaby to my custom_function.php and am able to limit amount of text on my rows when configuring the field I want to limit using Forms Configuration|Custom formatting function. It works fine on Pages based on Tables' but not for 'Pages based on Views'

I get error /views/results_grid.php on line 609 at the top of the able, if I scroll down the table I eventually get some data
 

Mbeauc636

New member
Forgot the error message:

multiple lines of ...~20

Notice: Undefined variable: where_field in /var/www/html/views/results_grid.php on line 609
 

eugenio

Administrator
Staff member
Hello,
my guess is that you didn't define a unique field (admin -> pages section) for the view.

Best,
 

Mbeauc636

New member
That's it ! It works.

I had to recreate my VIEW and add this additional field from one of the tables so that I could use it as the UNIQUE FIELD.

Thank you !
 

eugenio

Administrator
Staff member
Just an additional info: always configure a unique field for your tables/views because, apart from this problem, you can have other issues if you don't have it.

Best,
 

Mbeauc636

New member
Yes. I thought since I was giving a READ only View that not having a UNIQUE ID would be ok....guess this proves you need one !

Thanks again.

BTW: DADABIK has been a huge time saver for my project ! Good job on this !
 

eugenio

Administrator
Staff member
Mbeauc636 Wrote:
-------------------------------------------------------

> BTW: DADABIK has been a huge time saver for my pro
> ject ! Good job on this !

I am always happy to hear that, thanks! :)
 
Top