Project

General

Profile

MVC in Redmine 2.2.3 (?) Please help!

Added by Lennart Nordgreen almost 11 years ago

Hi,

I need help with the Model-View-Controller (MVC) structure in Redmine 2.2.3. I cant't get it to work.
I'm updating from Redmine 1.3.3 and our plugin which contain an edited base.html.erb (base.rhtml) is
not swaped out in version 2.2.3.

So the question is if MVC still is in effect (or bugged) in v.2.2.3?

I've looked here for reference but here I think he is using v.1.3.2.
http://www.packtpub.com/article/installing-and-customizing-redmine

Sysinfo:
Redmine version 2.2.3.stable
Ruby version 1.8.7 (x86_64-linux)
Rails version 3.2.12

Thanks for any help.

Regards,
Lennart


Replies (3)

RE: MVC in Redmine 2.2.3 (?) / custom layout and language - Added by Lennart Nordgreen almost 11 years ago

No one? Really..

I'm not a ruby guy just so you know, and the look of this I probably never will be..

This is what I want to achieve.

I have plugin with customized layout files and language file and which worked fine in Redmine 1.3.2
but doesn't work in v.2.2.3. I've tried so much different approaches to get these files to be rendered
instead of the original core variants. I've managed to hook a footer (located in my _base-html.erb),
that how far I've reach but when it come so shifting out a menu name, adding a help text and banner
(_form.html.erb) new/edit projects view I don't find any helpful topics on this.

How do I get my _base.html.erb, _from.html.erb and no.yml file to be rendered instead of the core counter part
files?

Here is the content of the init.rb file:

require 'redmine'

  1. Patches to the Redmine core.
    require 'dispatcher'

Redmine::Plugin.register :custom_layout do
name 'Custom Layout's'
author 'The missing link'
description 'Huzzah'
version '0.0.2'
end

The tree look like this: (look at the image I attached, this is not formatted correctly)

. |-- app | |-- controllers | |-- helpers | |-- models | `-- views | |-- layouts | | `-- _base.html.erb | |-- projects | | `-- _form.html.erb |-- assets | |-- images | |-- javascripts | `-- stylesheets |-- config | |-- locales | | `-- no.yml | | | `-- routes.rb |-- db | `-- migrate |-- init.rb |-- lib | |-- tasks
`-- README.rdoc

tree.png (13.9 KB) tree.png

RE: MVC in Redmine 2.2.3 (?) Please HELP! - Added by Jean-Baptiste Barth almost 11 years ago

I didn't fully understand your problem but just so you know:
  • redmine 2.x+ changed the location where plugin have to be installed ; they should now be in "plugins/" directory, not "vendor/plugins/" anymore
  • plugins need to be installed in a directory that strictly equals their declared name : here you register the plugin with "custom_layout", so the directory must be called "plugins/custom_layout" for the magic to happen
  • view overriding still works in redmine 2.x under these conditions, but file names must match too (there's no ".rhtml" in core for instance)
  • last but not least, if two plugins override the same view, you're screwed ; if you reach such a case you might consider using something more fine-grained like deface

Hope it helps a bit. Good luck

RE: MVC in Redmine 2.2.3 (?) Please help! - Added by Lennart Nordgreen almost 11 years ago

It did help and I'm greatfull Jean-Baptiste for your help.

The only thing I didn't get working was to override field labels with my customized language file
place in /config/locales/no.yml. Here I change the labels of roadmap .e.g, which worked in our
previous version of Redmine. I get our own defined hooks to work, which resides in our
customized _form.html.erb but I can't get the hooks provided in the original language file to be
overridden by our own labels.

I guess it has something to do with the dispatcher used in the old init.rb file to patch Redmine core and now I have
to do it some other way, adding some magic to the callback in the new init.rb file maybe.(?)

This is how my init.rb looked and looks now.

Old init.rb

# Patches to the Redmine core.
require 'dispatcher'

Redmine::Plugin.register :custom_layout do
  name 'Custom Layout's'
  author 'The missing link'
  description 'Huzzah'
  version '0.0.2'
end

New init.rb

require 'redmine'
ActionDispatch::Callbacks.to_prepare do 

end

Rails.logger.info 'Starting Custom Layout'

Redmine::Plugin.register :custom_layout do
  name 'Custom layout'
  author 'The missing link'
  description 'Huzzah'
  version '0.0.2'
end

    (1-3/3)