[opencms-dev] Locale macro in XSD schema
Arturo Martín Lladó
arturo.martin.llado at gmail.com
Mon Feb 18 12:28:09 CET 2013
Hi again, Christoph:
Thank you for your help!
Now more things are happening, but the method getStartingCategory()
stills not being called.
I see that the methods that are being called using the widget are:
- Empty constructor.
- setConfiguration(java.lang.String configuration)
- getConfiguration()
I guess that I can do what I need inside setConfiguration. I'll keep
you posted :-)
Kind regards,
Arturo.
2013/2/18 Christoph Fröhlich <cfauto at folge2.de>:
> Hi Arturo,
>
> sorry. I forgot that you have to overwrite
>
> newInstance()
>
> as well.
>
> /**
> * @see org.opencms.widgets.I_CmsWidget#newInstance()
> */
> public I_CmsWidget newInstance() {
>
> return new CmsLocaleCategoryWidget();
> }
>
> I hope this should do the trick.
>
> Regards
> Christoph
>
> Am 18.02.2013 um 12:05 schrieb Arturo Martín Lladó
> <arturo.martin.llado at gmail.com>:
>
> Hi, Christoph:
>
> It's really wierd. I have subclassed the widget like this:
>
> [...]
>
> public class CmsLocaleCategoryWidget extends CmsCategoryWidget {
>
> private static Log LOG = CmsLog.getLog(CmsLocaleCategoryWidget.class);
>
> public String getStartingCategory(CmsObject cms, java.lang.String
> referencePath) {
>
> LOG.error("== getStartingCategory, referencePath =>" + referencePath);
> LOG.error("== getStartingCategory =>" +
> super.getStartingCategory(cms, referencePath));
> return super.getStartingCategory(cms, referencePath);
>
> }
>
> }
>
> I also changed the XSD and opencms-vfs.xml in order to use the new widget.
>
> The "new" widget is rendered ok, showing categories, but I see no
> output in opencms.log. Even starting Tomcat on debug mode and adding a
> breakpoint on the method does not trigger anything. No stop in the
> method. It seems the method is not being called. I just don't get
> it...
>
> Thank you anyway for the help, Christoph. It is very welcome :-)
>
> Cheers.
>
> 2013/2/16 Christoph Fröhlich <cfauto at folge2.de>:
>
> HI Arturo,
>
> maybe you can create a custom widget by subclassing
> org.opencms.widgets.CmsCategoryWidget
>
>
> In the method
> getStartingCategory(CmsObject, String)
>
> you have access to the current locale. I think this should enable you to
> construct locale dependent starting categories.
>
> Regards
> Christoph
>
> Am 15.02.2013 um 17:51 schrieb Rüdiger Kurz <r.kurz at alkacon.com>:
>
> Hi,
>
> OK, enable the content managers to create categories and localize the
> display values is an argument. Anyway it would be better using the same
> taxonomy.
>
> If you have only two locales an 'ugly' workaround would be using two
> properties: simple and straight, but technical not clean. So why don't
> create an 'config' XSD that has multiple nested elements holding a category
> together with its display name. This will make it easy to edit the localized
> display values in a comfortable way for content managers and it would be
> technically clean.
>
> You could initialize this content with a Java Bean or what ever you need to
> make access easier than writing scriplet code.
>
> @Tobias, sorry but your mail comes in while I've already used the word
> 'ugly', anyway the property variant is simple and straight.
>
> regards
> Rüdiger
>
>
> Am 15.02.2013 17:18, schrieb Arturo Martín Lladó:
>
> Hi, Rüdiger.
>
> I can say it's a very original solution :-)
>
> Unfortunately, the categories should be administrated (and localized,
> they are siblings with different Title property) by the final users,
> and the edition of a Java properties file it's not a solution suitable
> for them.
>
> That's why we have a categories taxonomy like this:
>
> =====
> /_categories
> ca
> categories with locale "ca" configured as property by the parent
> [...]
> es
> categories with locale "es" configured as property by the parent
> [...]
> =====
>
> and that's why we'd like to offer to the final user a default category
> pointed using de "configuration" attribute of the CategoryWidget.
>
> Thank you anyway, Rüdiger. I really appreciate your help and any other
> tip about this problem will be very welcome.
>
> I guess that support for macros processing on the "configuration"
> attribute of the layout widgets could be part of the wishlist of the
> next release of OpenCms :-)
>
> Again, thanks for your help and have a nice weekend.
>
> Regards.
>
> 2013/2/15 Rüdiger Kurz <r.kurz at alkacon.com>:
>
> Hi,
>
> think you are right with your assumption. What you're trying to archive is
> localization of categories. I might be wrong, but I think that localizing
> categories,tags,facets,... does not make that much sense, since the 'tags'
> should be the same for one content. (Categories are assigned to VFS
> resources not to the real-localized content).
>
> However, I would try to use the same taxonomy for all languages and then
> localize its output at rendering time: The messages.properties could have
> entries per category path, using dots instead slashes and then on JSP side
> you will replace the slashes pf the category path with dotes and try then to
> receive the localized value.
>
> What do you think?
>
> Am 15.02.2013 16:49, schrieb Arturo Martín Lladó:
>
> Hi, Rüdiger.
>
> I tried with this:
>
> <resourcebundles>
> <xmlbundle name="element.workplace.xml">
> <bundle locale="ca">
> <resource
> key="package.element.language">ca</resource>
> </bundle>
> <bundle locale="es">
> <resource
> key="package.element.language">es</resource>
> </bundle>
> </xmlbundle>
> </resourcebundles>
>
> The value stored in %(key.package.element.language) is displayed OK in
> the default values of OpenCmsString fields, but it seems to be ignored
> in the attribute "configuration" of a CategoryWidget.
>
> Is this the expected behaviour? Maybe macros are not processed in
> <layout> elements?
>
> Kind regards.
>
> 2013/2/15 Rüdiger Kurz <r.kurz at alkacon.com>:
>
>
> Hi,
>
> it's me again. You can access localized message bundles with:
> %(key.your.label)
>
> imagine a XSD:
>
> <resourcebundle name="your.package.workplace"/>
> [...]
> <layout element="Elem"
> widget="CategoryWidget"
> configuration="... %(key.language) ..." />
>
> and a workplace_en.properties
> containing:
> language=en
>
> and a workplace_de.properties
> containing:
> language=de
>
> This should do the trick.
>
> regards
> Rüdiger
>
>
> Am 15.02.2013 14:39, schrieb Rüdiger Kurz:
>
> sorry not quiet sure if this works inside the XSD, but inside the
> content editor you can use it.
>
> Am 15.02.2013 14:37, schrieb Rüdiger Kurz:
>
>
>
> yes, %(request.locale)
>
> Am 15.02.2013 14:27, schrieb Arturo Martín Lladó:
>
>
>
> Hi, list.
>
> Is there available any locale macro for using it in XSD schemas?
>
> I'd like to do something like this:
>
> <layouts>
> [...]
> <layout element="Categoria" widget="CategoryWidget"
>
>
> configuration="category=/_categories/__LOCALE_MACRO___/tipoDocumento/|onlyleafs=true"/>
>
>
> </layouts>
>
> This is because our categories tree is organized this way:
> /sites/default/_categories/__LOCALE__/...
>
> Kind regards.
>
>
>
>
>
> --
> Rüdiger Kurz
>
> -------------------
>
> Alkacon Software GmbH - The OpenCms Experts
> Rüdiger Kurz
> An der Wachsfabrik 13
> 50996 Koeln, DE
>
> Tel: +49 (0)2236 3826-16
> Fax: +49 (0)2236 3826-20
> Email: r.kurz at alkacon.com
>
> http://www.alkacon.com
> http://www.opencms.org
>
> Geschäftsführer: Alexander Kandzior, Amtsgericht Köln, HRB 54613
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
>
>
>
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
>
>
>
>
> --
> Arturo Martín Lladó
>
>
> -------------------------------------------------
> Christoph Fröhlich
> Folge 3 GmbH
> Neuer Pferdemarkt 1
> 20359 Hamburg
>
> +49 +40 79 69 48 78
> cf at folge3.de
> http://www.folge3.de
> -------------------------------------------------
> Geschäftsführer: Christoph Fröhlich, Anja Künzel
> Handelsregister: HRB 105806, Amtsgericht Hamburg
>
>
>
>
>
>
>
--
Arturo Martín Lladó
More information about the opencms-dev
mailing list