/doc/tpl/admin/_admin_widget_i18n.tpl

http://github.com/zotonic/zotonic · Smarty Template · 63 lines · 48 code · 15 blank · 0 comment · 12 complexity · d18717140b0cd90fc9e91b199891abf1 MD5 · raw file

  1. {% extends "admin_edit_widget_i18n.tpl" %}
  2. {#
  3. More complex widget for editing language-depend content.
  4. Look at "doc/admin/tpl/_admin_widget_std.tpl" before start to develop i18n-enabled widget.
  5. Depending on whether mod_translation enabled or disabled:
  6. * if enabled, this widget will be displayed as tabs. See /admin/edit/1 top;
  7. * if disabled - will be displayed as standard widget.
  8. See /admin/edit/1 no-tabs widgets, like "address", etc.
  9. Before you delete this comment, you should understand: only blocks "widget_content" and "widget_i18n_tab_class"
  10. provide localization. They are will be rendered several times: one time per every enabled language.
  11. In other words, rendered once per lang tab.
  12. All other blocks are rendered only once - when page loads.
  13. #}
  14. {# See doc/admin/tpl/_admin_widget_std.tpl for block description. #}
  15. NOTE: displayed only then mod_translation is disabled. #}
  16. {% block widget_title %}{_ Basic _}{% endblock %}
  17. {# Optional CSS-classes for widget container #}
  18. {% block widget_i18n_tab_class %}item{% endblock %}
  19. {# See doc/admin/tpl/_admin_widget_std.tpl for block description. #}
  20. {% block widget_before %}{% endblock %}
  21. {# See doc/admin/tpl/_admin_widget_std.tpl for block description.
  22. See variables in doc/tpl/admin/README.i18n for i18n variables description.
  23. Tags inside this block should be ready for using in i18n and non-i18n enviroments. #}
  24. {% block widget_content %}
  25. {% with m.rsc[id] as r %}
  26. <fieldset class="admin-form">
  27. <div class="form-item clearfix">
  28. {# Then i18n is disabled, variables "lang_code", "lang_code_with_dollar" and others are undefined,
  29. so following ids and names goes to unlocalized identifiers. #}
  30. <label for="field-title{{ lang_code_with_dollar }}">{_ Title _} {{ lang_code_with_brackets }}</label>
  31. {# INPUT-tag: Look at name and value attributes: value is rendered using "if" filter: #}
  32. <input type="text" id="field-title{{ lang_code_with_dollar }}" name="title{{ lang_code_with_dollar }}"
  33. value="{{ is_i18n|if : r.translation[lang_code].title : r.title }}"
  34. {% if not is_editable %}disabled="disabled"{% endif %}/>
  35. </div>
  36. </fieldset>
  37. {% endwith %}
  38. {% endblock %}
  39. {# See doc/admin/tpl/_admin_widget_std.tpl for block description. #}
  40. {% block widget_after %}
  41. <script language="text/javascript">
  42. alert("Hello World!");
  43. </script>
  44. {% endblock %}
  45. {# Used only then mod_translation is disabled.
  46. See doc/admin/tpl/_admin_widget_std.tpl for description.
  47. NOTE: by now the content presence in this block is mandatory. #}
  48. {% block widget_show_minimized %}false{% endblock %}