Content
You are here:
Adding new block in "My Page"
Added by Jörg Delker almost 10 years ago
My environment: OpenProject 4.0.6 (installed on CentOS 6 from provided openproject-ce package)
I would like to add a new customized block to the available blocks list in “My Page”.
As suggested in EDITING PLUGINS, I followed the advise to copy the openproject-my_project_page plugin from ./vendored-plugins
to ./plugins
to add my customizations.
Unfortunately, I’m not successful to see any of my changes become active.
That may because I’m simply doing something fundamental wrong…
This is what I did:
- copy
./vendored-plugins/openproject-my_project_page
to./plugins
- changed the plugin entry in
Gemfiles.plugins
togem "openproject-my_project_page", :path => "plugins/openproject-my_project_page"
- added a new block as
plugins/openproject-my_project_page/app/views/my_projects_overviews/blocks/_work_packages_waiting_for_me.html.erb
- added locale entries for
label_work_packages_waiting_for_me
toconfig/locales/*.yml
Then I invoked
openproject-ce run bundle install --no-deployment
- service openproject-ce restart
After that I would’ve expected to see the added block in the MyPage Edit Page (/my/page_layout
).
But that’s not the case. Actually, nothing changed at all.
What am I doing wrong here?
Cheers
Jörg
Replies (4)
H Jörg,
I think you have the .erb in the wrong path. It should be:
vendored-plugins/openproject-my_project_page/app/views/my/blocks/
(‘my’ instead of ‘my_projects_overviews’).Furthermore, you could check if your version of the plugin is used via
openproject-ce run bundle show openproject-my_project_page
.And finally, if you think that this block is a good piece of code you could create a pull request against our github-repository. We are happy about every contribution. :)
Best,
Jonas
Hi Jonas,
thanks for responding and the good hint.
Unfortunately, there is no documentation on development of custom content-blocks, so some reverse engineering was necessary.
(Which is kind of hard, with very limited ruby background…)
While I figured from one of the vendered plugin code elements that custom content-blocks for the “project overview” page are expected in
app/views/my_project_overviews/blocks/_my_custom_block.erb
, I didn’t find the code that looks for the “My page” content blocks.However, you gave the hint to place those in
app/views/my/blocks/_my_custom_block.erb
, which worked perfectly.My code is available here.
Pull request is coming up.
Disclaimer: This is my 1st ruby code so far, so bare with me. It purely results from looking at other code and counting 1 and 1 together.
If this could be implemented much more elegant, feel free to fork and improve - I like to learn from that!
Hi Jörg,
yes, it is unfortunately that we do not have enough documentation. We try to fix that. Or, if you have mastered this riddle by now, you could create a short documentation. :)
Btw, your code looks good to me so far :+1:
I think I now found out what is the main cause for (my) confusion: There is a difference between my-project-page and the my-page. You probably know the following. But to be sure I just write it down again.
app/views/my_project_overviews/blocks
will be selectable when you personalize a project page. To see this, go to a project and click personalize this page on the upper right.That leads to the following places to store blocks:
my_project_overview/blocks
(see the code here)Unfortunately, if you want to create pull request then you can only create one against OpenProject or against OpenProject-My_Project_Overview. So you would have to split your repository up. You can find a more detailed explanation here. That way, your blocks would automatically be in the community edition.
Or maybe you want to add this as it is: as a plugin. But right now, I’m not sure how we would handle it. We are thinking about doing more with rubygems.
So it may be possible to kind of release it as a plugin. But for now it would be easier to include into the existing repositories. What do you think?
Best,
Jonas
Hi Jonas,
thanks for summarizing the facts again. I recon that we had the same “confusion” here ;)
And thanks again for your mind-reading about the pull request. I’ve broke my head about that exact problem.
For now, I decided to leave this as a single external plugin and postpone the pull request.
In it’s current state, the code would probably not fit very well in the community edition anyhow, because the type of workpackages that are evaluated is hard-coded (due to my lack of knowledge how to implement a plugin config page yet).
As soon as I’ve found a clue on that and made that types configurable, I’ll probably fork the particular community-edition repos and transplant the code.
Then a pull request will be easy.
Thanks for your support,
Jörg