Redmine Cookbook
上QQ阅读APP看书,第一时间看更新

Customizing the layout of the project entry page

If built-in customizations don't fit your needs and you need to edit Redmine's views manually for some reason, this recipe will show you how to make New project private in Redmine, and how to remove the Homepage field on the New project creation form.

Getting ready

Make sure that you have access to your working Redmine installation.

How to do it…

To accomplish the goal of making the project private by default by having the checkbox at the project creation form unchecked by default in Redmine, you need to navigate to Administration | Settings | Projects. Untick the New projects are public by default checkbox, and click Save.

To hide the Homepage textbox and label, use your favorite code editor with Ruby highlight, navigate with the file browser or via the command line to your Redmine installation folder, open redmine/app/views/projects/_form.html.erb, find the line containing <p><%= f.text_field :homepage, :size => 60 %></p>, and delete it. Restart Redmine and make sure that the creation of new projects change is reflected, as in the following screenshot:

How it works…

What we did here is deliberately combine built-in Redmine feature customization with code editing customization so that you learn to seek for built-in customizations before reaching out for the code editor. Therefore, first, we navigate to the Settings menu and disable the active checkbox for projects to be public. So, from now on, without restarting Redmine on a new project entry form, the Public checkbox will be unchecked by default. After this, we used a code editor and edited the app/views/projects/_form.html.erb file by removing the line that displays the Homepage field, and restarted Redmine to reflect this update.

There's more…

If you need to change the Issue entry form or any other form, you can use this same principle. Just find the view files that you need to edit, make the customization, restart Redmine, and view your change.

See also

Refer to the Starting and Restarting Redmine recipe from Chapter 5, Regular and Planned Maintenance.