Adding New tables & columns??

Post about your customizations to share with others.

Moderators: Developer, Contributor

mickey
Posts: 22
Joined: 06 Apr 2006, 05:04
Location: Cleveland, OH

Adding New tables & columns??

Post by mickey »

Installed mantis v1.0.1 and it looks and runs great. Now, is it possible to add new tables to existing mantis database? Also, how to add new columns to Report_Bug page?
atomoid
Posts: 108
Joined: 18 Aug 2005, 00:46
Location: santa cruz, ca

Post by atomoid »

oops, maybe i misunderstood the question? If not then see the thread to customize the 'View Issues' page. http://forums.mantisbt.org/viewtopic.ph ... highlight=.

But if you want to make new database fields that will appear in the report page and everywhere else you set them to show up, just create some new Custom Fields. okay thats not much help but hopefully someone else has a better answer for you.
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

I agree with Atomoid.

Unless you have a super-duper reason for it otherwise, use custom fields. Trust me: you'll appreciate it when you don't have to merge code!
mickey
Posts: 22
Joined: 06 Apr 2006, 05:04
Location: Cleveland, OH

Post by mickey »

Thanks a ton Atomoid, Narcissus. Your suggestions are very very helpful, especially to me who is very new here. I tried out as per your instructions and see the custom fields in View_all_bugs and View page. Is there anyway I can add custom fields to Report_Issue (bug_report_page) as well?

I’ve a few more questions. How can I add additional menus to top menu (next to “Main”or “My View”). The reason I ask whether I can add new tables is that, I want to include forms for employees data, time cards etc. Do you have any suggestions?

Thank you once again.
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

Mickey:

In theory, they should already be there. Check that they're not just on the advanced report page, too. They are further down the page than most of the other fields...

Regarding the menu items at the top of the page, check out $g_main_menu_custom_options in your config_defaults_inc.php file (as always, be sure to set your own in config_inc.php, though!).

Hope that helps,
Lincoln.
mickey
Posts: 22
Joined: 06 Apr 2006, 05:04
Location: Cleveland, OH

Post by mickey »

Thank you Narcissus, I’m trying out adding menu options as you mentioned. Will keep you posted.
Regarding adding custom fields, I still am not able to see new fields in bug_report_page.php. I don’t see it in view.php either now :cry: . I can see the new field only in View_Issues page. Checked the settings for newly added field (I call it test_field) under Manage Custom Fields menu (manage_custom_field_edit_page.php) and its as below.

Name: test_field
Type: Enumeration
Possible Values: <blank>
Default Value: <blank>
Regular Expression: <blank>
Read Access: administrator
Write Access: Administrator
Min. Length: 0
Max. Length: 0
Display Only On Advanced page: <unchecked>
Display When Reporting Issues: <checked>
Display When Updating Issues: <checked>
Display when Resolving Issues: <checked>
Display When Closing Issues: <checked>
Required On Report : <checked>
Required On Update: <checked>
Required on Resolve: <checked>
Required On Close: <checked>

Code wise, it's exactly same as what you and Atomoid had mentioned in your previous posts. Do you see anything wrong with what I’m doing?

Thank you,
Mickey.
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

Assuming you're logged in as Administrator when trying to report the issue (ie. assuming you match / exceed the permissions limits), I would check your project settings.

Each custom field needs to be assigned to each project that you want to use that field in. Maybe the projects you're looking in don't have the custom field assigned to it?
mickey
Posts: 22
Joined: 06 Apr 2006, 05:04
Location: Cleveland, OH

Post by mickey »

Thank you Narcissus.. you can't be more right:) Once I assigned custom field to one of the projects, I can see it now in report bug page.
atomoid
Posts: 108
Joined: 18 Aug 2005, 00:46
Location: santa cruz, ca

menu options

Post by atomoid »

now that i think of it, i'd like to add just a single item to the menu, but it gives an example thats puzzling to me:

Code: Select all

g_main_menu_custom_options.php = array( array( "my link", MANAGER, 'my_link.php'), array( "my link2", ADMINISTRATOR, 'my_link2.php') );
now, how do i approach setting up that 'my_link.php' php page? its probably elementary but ive never tried anything like this. I guess i could also just wipe out the second link reference since i wont need it.
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

It all depends, really.

You don't have to point it to a PHP file specifically, you can point it anywhere you want.

If you want the file that you're linking to to maintain the Mantis look and feel, then the best thing to do is copy some other page, rename it and edit it until it looks right.

If you don't care how it looks, just put in the URL for wherever the page is. That is say, you could actually make a link such as:
array( "Google", MANAGER, 'http://www.google.com')

I hope that makes a bit more sense...
Lincoln.
atomoid
Posts: 108
Joined: 18 Aug 2005, 00:46
Location: santa cruz, ca

Post by atomoid »

That was the first thing i tried (just pasting the hyperlink in there instead of the php file reference) but it didnt work, instead, it makes an extra place for it there second from last but its empty:
"blahblahblah...| Manage | Edit News | My account | | Logout "

I guess i need to create a php file to spit out the link. so i just put a print statement in the php file or something? okay i tried that:

config_inc.php (doesnt work):

Code: Select all

g_main_menu_custom_options.php = array ( "my link", MANAGER, 'my_link.php');
my_link.php:

Code: Select all

<?php
PRINT 'http://mars.lyle.org/';
?>
ok so that doesnt work. i also tried the 'original' format for the config_inc.php (works):

Code: Select all

g_main_menu_custom_options.php = array( array( "my link", MANAGER, 'my_link.php'), array( "my link2", MANAGER, 'my_link2.php') );
okay i dont know why the array has to be inside another array, but as long as thats what works (this also works):

Code: Select all

g_main_menu_custom_options.php = array( array( "my link", MANAGER, 'my_link.php'));
but now when i click on the link, it just prints out the link in the browser, but of course i want to to actually open that link not just print it. i must be a noob! how can i make a simple php page that will simply call the link?
mickey
Posts: 22
Joined: 06 Apr 2006, 05:04
Location: Cleveland, OH

Post by mickey »

Atomoid, I tried doing the same. To begin with, for testing, I added
the following in config_inc.php

Code: Select all

$g_main_menu_custom_options = array( array( "Employees", MANAGER, 'employee_page.php') );
employee_page.php here is just a copy of account_page.php. Started with one of the php files already in mantis system so that all my pages have same basic template.

I tried the same code with a link to http://www.mantisbt.org as well and it worked fine.

Mickey
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

I'm in the same boat as mickey: just tried it and it works as expected :(

The one thing I would check, though, is that your code is correct. The line that you copied here is:
g_main_menu_custom_options.php = array( array( "my link", MANAGER, 'my_link.php'));

Instead of starting:
g_main_menu_custom_options.php =

it needs to be:
$g_main_menu_custom_options =

Not sure if that was your problem or not, though!
atomoid
Posts: 108
Joined: 18 Aug 2005, 00:46
Location: santa cruz, ca

doh!

Post by atomoid »

you're correct, (no, i didnt have the .php at the end, i had just copy/pasted the string from this forum into my reply), the problem was that i hadnt tried to use the URL with the 'original' format (i had given up after trying it with my 'simplified' format, since it was still able to make the placeholder for the link so i assumed that wasnt the problem, but you know what happens when you assume...).

so, i still cant figure out why you need to have the array inside the array though..

but anyway its fixed!
thanks!


...on another note...
how would one try to make the link open in a sepatarate window/tab?
I tried using html target tag, 'slipping it in in a variety of ways to no avail, i guess if i changed the code that generates these links then they would all open in separate windows which is not desired... (but anyway it was interesting to see what happens when i tried -it usually turns into a link to the the current bug or to my link appended to the mantis url, oddly enough)
Narcissus
Developer
Posts: 338
Joined: 17 Feb 2005, 09:45

Post by Narcissus »

You need the array inside the array because of the fact that each link is an array of data, and you want an array of links.

Even if you're just using one link, it still needs to be placed into an array so that the code can iterate over it...

Regarding making a link go into its own popup. A 'hack' that I just tried is to append

Code: Select all

" target="_blank
to your link.

eg. if your link was defined by the array:
array( "My Link", MANAGER, 'my_link.php' )

make it:
array( "My Link", MANAGER, 'my_link.php" target="_blank' )

That is basically an 'HTML injection', but should work fine...

Hope that helps,
Lincoln.
Post Reply