Question

How can I get the wiki title in my Redmine wiki page?

I get the name of the project with context[:project].identifier, and I tried context[:wiki] but it doesn't work ...

I'm using Redmine 1.4.4, and here my code:

EDIT: # my_plugin/lib/hooks.rb

class MkdocHookListener < Redmine::Hook::ViewListener
  def view_layouts_base_content(context={})
    @content =  ""
    if context[:controller].is_a?(WikiController)
      @content << "<br/>projet ="
      @content << context[:project].identifier
    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

Thanks !

EDIT: I just want to get the wiki title on the wiki-page, then I can use my home-made plugin.

Was it helpful?

Solution

I finally figured it out! It's not a very good way ... but it works ...

@url = context[:request].env["REDIRECT_URL"]
@url = @url.to_s.split('/')
@length = @url.length - 1
@title = @url[@length]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top