select what columns to view
Moderators: Developer, Contributor
select what columns to view
vboctor resolve the bug #934 by following post:
"This can now be controlled by overriding the custom function:
custom_function_default_get_columns_to_view()"
Can anyone help me to find this function ?
"This can now be controlled by overriding the custom function:
custom_function_default_get_columns_to_view()"
Can anyone help me to find this function ?
Re: select what columns to view
My Mantis BT ver is 0.19.2DoCToR wrote:vboctor resolve the bug #934 by following post:
"This can now be controlled by overriding the custom function:
custom_function_default_get_columns_to_view()"
Can anyone help me to find this function ?
1.0.0 alpha is out and supports this functionality, although it's not thoroughly documented.
To modify the columns displayed, create a file in the root directory called:
custom_functions_inc.php
Add this following code to the file (taken from /core/custom_functions_api.php lines 139-178, but with the function name changed from custom_function_default_* to custom_function_override_*):
The order that the column names are added to the array is the order they display, left to right. Custom fields can be added by using "custom_" before the name you gave the field in the Mantis "Manage Custom Fields" menu (Yes, including spaces and capitals you probably used for formatting).
Example: I created a custom field named "Due Date", so I inserted this code on the 3rd to last line of the above function:
HTH
To modify the columns displayed, create a file in the root directory called:
custom_functions_inc.php
Add this following code to the file (taken from /core/custom_functions_api.php lines 139-178, but with the function name changed from custom_function_default_* to custom_function_override_*):
Mantis will now use the custom override function for the columns to view, but since it's a copy of the default function, you'll get the same results as when "stock." Make your changes from here to get the columns to display as you wish.<?php
# --------------------
# returns an array of the column names to be displayed.
# The column names to use are those of the field names in the bug table.
# In addition, you can use the following:
# - "selection" for selection checkboxes.
# - "edit" for icon to open the edit page.
# - "custom_xxxx" were xxxx is the name of the custom field that is valid for the
# current project. In case of "All Projects, the field will be empty where it is
# not applicable.
function custom_function_override_get_columns_to_view( $p_print = false ) {
$t_columns = array();
$t_columns[] = 'selection';
if ( !$p_print ) {
$t_columns[] = 'edit';
}
$t_columns[] = 'priority';
$t_columns[] = 'id';
$t_enable_sponsorship = config_get( 'enable_sponsorship' );
if ( ON == $t_enable_sponsorship ) {
$t_columns[] = 'sponsorship';
}
$t_columns[] = 'bugnotes_count';
$t_show_attachments = config_get( 'show_attachment_indicator' );
if ( ON == $t_show_attachments ) {
$t_columns[] = 'attachment';
}
$t_columns[] = 'category';
$t_columns[] = 'severity';
$t_columns[] = 'status';
$t_columns[] = 'last_updated';
$t_columns[] = 'summary';
return $t_columns;
}
?>
The order that the column names are added to the array is the order they display, left to right. Custom fields can be added by using "custom_" before the name you gave the field in the Mantis "Manage Custom Fields" menu (Yes, including spaces and capitals you probably used for formatting).
Example: I created a custom field named "Due Date", so I inserted this code on the 3rd to last line of the above function:
This results in that custom field being displayed on the right-hand side of the "View Issues" list.$t_columns[] = 'custom_Due Date';
HTH
Thanks to Mike, thats a handy intruduction.
Im using Mantis 1.0.1
When i try this it seems to work (sort of), but i get the message:
----
SYSTEM WARNING: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\mantis\custom_functions_inc.php:72)
----
...and when i try to add in the "resolution" field to the list of columns, all that gets displayed are the enumeration values (10, 20, etc) instead of the text (closed, open, etc).
There is no file named: "custom_functions_api.php".
But I found one called: "custom_function_api.php".
The file's contents have changed quite a bit, which is probably due to the fact that this file (7/23/05) is newer than Mike's post.
So I redid it completely following the example but instead using lines 139 to 210 (and of course editing the function name with 'override' and enclosing the whole thing inside a php script (<?php... ...?>).
Unfortunately, the same two problems noted above still exist.
I find that if i directly edit the mantis/core/custom_function_api.php file to add in the "resolution" field to a new line 204:
$t_columns[] = 'resolution';
Then the SYSTEM WARNING error goes away,
but the listed field values are still enumeration numbers...
Im using Mantis 1.0.1
When i try this it seems to work (sort of), but i get the message:
----
SYSTEM WARNING: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\mantis\custom_functions_inc.php:72)
----
...and when i try to add in the "resolution" field to the list of columns, all that gets displayed are the enumeration values (10, 20, etc) instead of the text (closed, open, etc).
There is no file named: "custom_functions_api.php".
But I found one called: "custom_function_api.php".
The file's contents have changed quite a bit, which is probably due to the fact that this file (7/23/05) is newer than Mike's post.
So I redid it completely following the example but instead using lines 139 to 210 (and of course editing the function name with 'override' and enclosing the whole thing inside a php script (<?php... ...?>).
Unfortunately, the same two problems noted above still exist.
I find that if i directly edit the mantis/core/custom_function_api.php file to add in the "resolution" field to a new line 204:
$t_columns[] = 'resolution';
Then the SYSTEM WARNING error goes away,
but the listed field values are still enumeration numbers...
Atomoid:
Just to start with, the system warning is probably coming from whitespace outside of the <?php and ?> tags. As you can see in the error, it says that the output started in your custom_functions_inc.php file on line 72.
If that is the end of your file, then that's the culprit. Make sure that you have no space outside of those php tags. This means not even a new line!
For the other problem, it may be best to post the code that you have written so that we can see exactly what the issue is...
Lincoln.
Just to start with, the system warning is probably coming from whitespace outside of the <?php and ?> tags. As you can see in the error, it says that the output started in your custom_functions_inc.php file on line 72.
If that is the end of your file, then that's the culprit. Make sure that you have no space outside of those php tags. This means not even a new line!
For the other problem, it may be best to post the code that you have written so that we can see exactly what the issue is...
Lincoln.
addin column problem
Yes, you're right i had a no-see-um bugger at the end of my file, removing it fixed the error. Thanks for that!
As for the enumeration numbers appearing instead, I haven't figured that out. Maybe there needs to be some argument passed that will grab the enumerated reference instead of just calling the enumeration value itself, but i dont know why it works for 'severity' and 'status' which are enumerated values as well.
I tried all the fields and all these come out enumeration numbers:
Reproducibility
Projection
ETA
View Status
Resolution
I think if you try this you'll run into the same problem. My code is just copied from core/custom_function_api.php (lines 140-209) with minor edits to make it an .inc file, but here it is:
----------- contents of mantis/custom_functions_inc.php ------------
<?php
# --------------------
# returns an array of the column names to be displayed.
# The column names to use are those of the field names in the bug table.
# In addition, you can use the following:
# - "selection" for selection checkboxes.
# - "edit" for icon to open the edit page.
# - "custom_xxxx" were xxxx is the name of the custom field that is valid for the
# current project. In case of "All Projects, the field will be empty where it is
# not applicable.
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function custom_function_override_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns = array();
if ( $p_columns_target == COLUMNS_TARGET_CSV_PAGE ) {
$t_columns[] = 'id'; // localized: 'id',
$t_columns[] = 'project_id'; // 'email_project'
$t_columns[] = 'reporter_id'; // 'reporter'
$t_columns[] = 'handler_id'; // 'assigned_to'
$t_columns[] = 'priority'; // 'priority'
$t_columns[] = 'severity'; // 'severity'
$t_columns[] = 'reproducibility'; // 'reproducibility'
$t_columns[] = 'version'; // 'version'
$t_columns[] = 'projection'; // 'projection'
$t_columns[] = 'category'; // 'category'
$t_columns[] = 'date_submitted'; // 'date_submitted'
$t_columns[] = 'eta'; // 'eta'
$t_columns[] = 'os'; // 'os'
$t_columns[] = 'os_build'; // 'os_version'
$t_columns[] = 'platform'; // 'platform'
$t_columns[] = 'view_state'; // 'view_status'
$t_columns[] = 'last_updated'; // 'last_update'
$t_columns[] = 'summary'; // 'summary'
$t_columns[] = 'status'; // 'status'
$t_columns[] = 'resolution'; // 'resolution'
$t_columns[] = 'fixed_in_version'; // 'fixed_in_version';
if ( OFF == config_get( 'enable_relationship' ) ) {
$t_columns[] = 'duplicate_id'; // 'duplicate_id'
}
} else {
$t_columns[] = 'selection';
if ( $p_columns_target == COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns[] = 'edit';
}
$t_columns[] = 'priority';
$t_columns[] = 'id';
$t_enable_sponsorship = config_get( 'enable_sponsorship' );
if ( ON == $t_enable_sponsorship ) {
$t_columns[] = 'sponsorship_total';
}
$t_columns[] = 'bugnotes_count';
$t_show_attachments = config_get( 'show_attachment_indicator' );
if ( ON == $t_show_attachments ) {
$t_columns[] = 'attachment';
}
$t_columns[] = 'category';
$t_columns[] = 'severity';
$t_columns[] = 'status';
$t_columns[] = 'resolution'; // add 'resolution' column to bug list view
$t_columns[] = 'last_updated';
$t_columns[] = 'summary';
}
return $t_columns;
}
?>
-----------------------------------------------------------
As for the enumeration numbers appearing instead, I haven't figured that out. Maybe there needs to be some argument passed that will grab the enumerated reference instead of just calling the enumeration value itself, but i dont know why it works for 'severity' and 'status' which are enumerated values as well.
I tried all the fields and all these come out enumeration numbers:
Reproducibility
Projection
ETA
View Status
Resolution
I think if you try this you'll run into the same problem. My code is just copied from core/custom_function_api.php (lines 140-209) with minor edits to make it an .inc file, but here it is:
----------- contents of mantis/custom_functions_inc.php ------------
<?php
# --------------------
# returns an array of the column names to be displayed.
# The column names to use are those of the field names in the bug table.
# In addition, you can use the following:
# - "selection" for selection checkboxes.
# - "edit" for icon to open the edit page.
# - "custom_xxxx" were xxxx is the name of the custom field that is valid for the
# current project. In case of "All Projects, the field will be empty where it is
# not applicable.
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function custom_function_override_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns = array();
if ( $p_columns_target == COLUMNS_TARGET_CSV_PAGE ) {
$t_columns[] = 'id'; // localized: 'id',
$t_columns[] = 'project_id'; // 'email_project'
$t_columns[] = 'reporter_id'; // 'reporter'
$t_columns[] = 'handler_id'; // 'assigned_to'
$t_columns[] = 'priority'; // 'priority'
$t_columns[] = 'severity'; // 'severity'
$t_columns[] = 'reproducibility'; // 'reproducibility'
$t_columns[] = 'version'; // 'version'
$t_columns[] = 'projection'; // 'projection'
$t_columns[] = 'category'; // 'category'
$t_columns[] = 'date_submitted'; // 'date_submitted'
$t_columns[] = 'eta'; // 'eta'
$t_columns[] = 'os'; // 'os'
$t_columns[] = 'os_build'; // 'os_version'
$t_columns[] = 'platform'; // 'platform'
$t_columns[] = 'view_state'; // 'view_status'
$t_columns[] = 'last_updated'; // 'last_update'
$t_columns[] = 'summary'; // 'summary'
$t_columns[] = 'status'; // 'status'
$t_columns[] = 'resolution'; // 'resolution'
$t_columns[] = 'fixed_in_version'; // 'fixed_in_version';
if ( OFF == config_get( 'enable_relationship' ) ) {
$t_columns[] = 'duplicate_id'; // 'duplicate_id'
}
} else {
$t_columns[] = 'selection';
if ( $p_columns_target == COLUMNS_TARGET_VIEW_PAGE ) {
$t_columns[] = 'edit';
}
$t_columns[] = 'priority';
$t_columns[] = 'id';
$t_enable_sponsorship = config_get( 'enable_sponsorship' );
if ( ON == $t_enable_sponsorship ) {
$t_columns[] = 'sponsorship_total';
}
$t_columns[] = 'bugnotes_count';
$t_show_attachments = config_get( 'show_attachment_indicator' );
if ( ON == $t_show_attachments ) {
$t_columns[] = 'attachment';
}
$t_columns[] = 'category';
$t_columns[] = 'severity';
$t_columns[] = 'status';
$t_columns[] = 'resolution'; // add 'resolution' column to bug list view
$t_columns[] = 'last_updated';
$t_columns[] = 'summary';
}
return $t_columns;
}
?>
-----------------------------------------------------------
Hi atomoid:
Looks like a bug. Add this function to your columns_api.php file in your core directory:
# --------------------
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function print_column_resolution( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
echo '<td class="center">';
echo get_enum_element( 'resolution', $p_row['resolution'] );
echo '</td>';
}
I have another, more generic way of fixing this, but it's better to stay with this way for the time being...
Hope this helps,
Lincoln.
Looks like a bug. Add this function to your columns_api.php file in your core directory:
# --------------------
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function print_column_resolution( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
echo '<td class="center">';
echo get_enum_element( 'resolution', $p_row['resolution'] );
echo '</td>';
}
I have another, more generic way of fixing this, but it's better to stay with this way for the time being...
Hope this helps,
Lincoln.
I think i misunderstood someone elses question so i removed it from that thread and put it here where it belongs...
since many columns arent supported and you get unusable data, you have had to write it yourself. for instance, i added this to my custom_functions_inc.php file to show a few extra fields:
but that generates just the table values which may be enumeration or unix values so you also have to support these in the core/columns_api.php:
...then they display correctly in the view_all_bug_page
since many columns arent supported and you get unusable data, you have had to write it yourself. for instance, i added this to my custom_functions_inc.php file to show a few extra fields:
Code: Select all
$t_columns[] = 'resolution'; // add 'resolution' column to bug list view
$t_columns[] = 'reporter_id'; // add 'reporter' column to bug list view
$t_columns[] = 'date_submitted'; // add 'date_submitted' column
Code: Select all
# --------- my tweak ----------
# ------------------- to get RESOLUTION value to enumerate properly in list view
# -------------------
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
function print_column_resolution( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
echo '<td class="center">';
echo get_enum_element( 'resolution', $p_row['resolution'] );
echo '</td>';
}
Code: Select all
# --------- my function -----------
# --------------------
# $p_columns_target: see COLUMNS_TARGET_* in constant_inc.php
# --------------------
function print_column_date_submitted( $p_row, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE ) {
global $t_filter;
$t_date_submitted = date( config_get( 'short_date_format' ), $p_row['date_submitted'] );
echo '<td class="center">';
if ( $p_row['date_submitted'] > strtotime( '-'.$t_filter['highlight_changed'].' hours' ) ) {
printf( '<span class="bold">%s</span>', $t_date_submitted );
} else {
echo $t_date_submitted;
}
echo '</td>';
}
custom field enabled for certain projects
Hi,
thanks a lot for this tutorial.
I would like to include a custom field only it that is enabled for that project, what is the solution for this?
The second question is that I don't really know what is difference between (multiselection) list and enumeration?
Thanks a lot,
Illes
thanks a lot for this tutorial.
I would like to include a custom field only it that is enabled for that project, what is the solution for this?
The second question is that I don't really know what is difference between (multiselection) list and enumeration?
Thanks a lot,
Illes
Maybe i misunderstand your question, but whenever you create a custom field you must specifically include it in whatever project you want it to be used in, otherwise you wont see it anywhere. So thats all built-in.
As far as enumerations vs multiselection goes, we use enumerations because of the way the list works. read this manual page for more info http://manual.mantisbt.org/manual.custo ... mantis.php
Aside from that, sometimes its better to create two almost identical custom fields and assign each to a particular project if your entered values dont really make sense in both projects, and it helps keep the list clutter down.
As far as enumerations vs multiselection goes, we use enumerations because of the way the list works. read this manual page for more info http://manual.mantisbt.org/manual.custo ... mantis.php
Aside from that, sometimes its better to create two almost identical custom fields and assign each to a particular project if your entered values dont really make sense in both projects, and it helps keep the list clutter down.