Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

mod_admin(_frontend): More flexible block handling #666

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
4 participants
Contributor

hanikesn commented Sep 23, 2013

This change allows other modules to provide custom javascript/wires for their own blocks.

Suggestions are welcome!

@hanikesn hanikesn mod_admin(_frontend): More flexible block handling
This change allows other modules to provide custom javascript/wires for their own blocks.
1eed05e

@kaos kaos commented on the diff Sep 23, 2013

modules/mod_admin/templates/_admin_edit_blocks.tpl
@@ -10,6 +10,8 @@
</div>
{% endwith %}
+{% all include "_admin_edit_blocks_additional.tpl" %}
@kaos

kaos Sep 23, 2013

Owner

I would go with adding an empty {% block additional %}{% endblock %} here. That way you don't have the template go running around looking for all include unnecessarily..

To use it, simply drop override it with your own version of _admin_edit_blocks.tpl and then use overrules to inject your code into the "additional" block.

@hanikesn

hanikesn Sep 23, 2013

Contributor

Would this also work if multiple modules want to extend this? I wrote a small slider module (https://bitbucket.org/zeitmacht/mod_zm_slider).

Which uses observe_admin_edit_blocks to register a new block type and provides a admin_edit_block_li...tpl and a block_view...tpl. But I need to put additional javascript/wires to the edit page, to provide custom functionality. Specifically:
https://bitbucket.org/zeitmacht/mod_zm_slider/src/7ce1712190a341baa911d4763d1869b97d5bd1dc/templates/_admin_edit_blocks_additional.tpl?at=master

Would there be any better way to do this? I guess I could put this somewhere else so that it gets included on the edit page.

@kaos

kaos Sep 23, 2013

Owner

Not sure what happens if there's a chain of modules using overrules.. @mworrell ?

There is a _admin_edit_js.tpl file included from admin_edit.tpl which sounds nice. Maybe patch that to be a all include instead of just include.
https://github.com/zotonic/zotonic/blob/master/modules/mod_admin/templates/admin_edit.tpl#L68

@mworrell

mworrell Sep 23, 2013

Owner

A chain is just like you say it is - a chain.

You can always use {% inherit %} to echo the block value of the template next-up in the chain.

I agree that the js-files might be the best place to add extra javascript, now that you mentioned it.

Contributor

hanikesn commented Oct 23, 2013

So, I'm trying to wrap up this pull request. I witnessed myself, that all include is very slow. (I deleted two all includes from my base template and reduced response times by ~50ms).

I agree, that the overrules method is better. But I'm hesitant to put it in admin_edit.tpl as it belongs to the block editing. What about a new file: _admin_edit_blocks_js.tpl included in admin_edit_blocks.tpl with all the javascript from _admin_edit_blocks.tpl, too?

Owner

arjan commented Sep 30, 2014

Closing due to inactivity.
See #830 for mention of all include performance

@arjan arjan closed this Sep 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment