Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

Development
  1. OpenProject
  2. Forums
  3. Development
  4. [Plugin Development] How to use a helper from hook view template?

[Plugin Development] How to use a helper from hook view template?

Added by Tomáš Jukin over 11 years ago

Hi Guys,

I have an issue when porting ChilliProject TimeTracker plugin (https://github.com/magiclabs/ChiliProject-TimeTracker) to OP.

I have used the openproject-plugin generator and took inspiration from the openproject-backlogs plugin, but my hooks templates are not able to see helpers (I have the classic rails engine app structure).

How is possible to use helper from the hook template?

AFAIK in the case of hook none from controllers of the plugin are used, therefore I need to include the helper somehow differently. How?

Thanks,

Kind regards
Tomáš


Replies (3)

RE: [Plugin Development] How to use a helper from hook view template? - Added by Hagen Schink over 11 years ago

Hello Tomáš,

have you had a look into code>hooks.rb ? As far as I know you simply include the helpers you need (like WorkPackageHelper in hooks.rb).

Have you published your code already? If yes, we may have a look into it?

Kind regards,
Hagen

RE: [Plugin Development] How to use a helper from hook view template? - Added by Tomáš Jukin over 11 years ago

Hello Hagen,

I have not published it yet, because I would like to publish the working version of it.

Yes, I have looked at hooks.rb and done it in the same way, my hooks.rb in the TimeTracker plugin looks like this:

# This class hooks into Redmine's View Listeners in order to add content to the page
module OpenProject::TimeTracker::Hooks
    class LayoutHook < Redmine::Hook::ViewListener
        include ApplicationHelper
        include TimeTrackersHelper

        render_on :view_layouts_base_body_bottom, :partial => 'time_trackers/update_menu'
        render_on :view_issues_context_menu_start, :partial => 'time_trackers/update_context'
        render_on :view_layouts_base_sidebar, :partial => 'time_trackers/embed_menu'
    end
end

But it does not work :-(. Methods from my helpers are not defined in my hook templates…

An idea?

RE: [Plugin Development] How to use a helper from hook view template? - Added by Hagen Schink over 11 years ago

Hello Tomáš,

so, now I am little bit confused. :-)

The ApplicationHelper in line 4, is it your own or do you try to include core’s ApplicationHelper?. If you try the latter, you may remove the include because the code>ViewListener already includes it.

At the moment I just think that the modules/namespaces are mixed up. But that is just a guess. ;-)

Kind regards,
Hagen

  • (1 - 3/3)
Loading...