Project

General

Profile

Add a new item in 'Also available in' menu

Added by Eloise Chizat about 10 years ago

Hi everybody,

I'm new in Redmine plugin developement.
I'm using Redmine 1.4.4 and I made a plugin that I want to link in the 'Also available in' menu. (After "PDF | HTML | TXT" for example in the wiki page)

How can I do? Any tutorial ?

Thanks =)


Replies (2)

RE: Add a new item in 'Also available in' menu - Added by Eloise Chizat about 10 years ago

So, I found the way!
I use a Hook.

# my_plugin/lib/hooks.rb

class MkdocHookListener < Redmine::Hook::ViewListener
  def view_layouts_base_content(context={})
    @content = "" 
    if defined?(context[:project].identifier)
      @content << "Here my text!" 
    end
    return content_tag("p align='right'", @content)
  end
end

# myplugin/init.rb:

require 'redmine'
require_dependency 'hooks'

Redmine::Plugin.register :my_plugin do
  ...
end

Now, I have a new issue...

"Here my text!" was in all redmine page, so I add "if defined?(context[:project].identifier)" and "Here my text!" is in all project page.

How can I do if I just want it to appears in all wiki page ?

Thanks!

RE: Add a new item in 'Also available in' menu - Added by Eloise Chizat about 10 years ago

Here the answer :

class MkdocHookListener < Redmine::Hook::ViewListener
  def view_layouts_base_content(context={})
    @content =  "" 
    if defined?(context[:project].identifier)
      if context[:controller].is_a?(WikiController)
        @content << "my text here" 
      end
    end
    return content_tag("p align='right'", @content)
  end
end
    (1-2/2)