Hi Petr,

Some notes inline:

     -----Ursprüngliche Nachricht-----
     Von: [email protected] 
[mailto:[email protected]] Im Auftrag von Petr Kadlec (via 
Magnolia Forums)
     Gesendet: Mittwoch, 25. Juli 2012 20:52
     An: Magnolia User List
     Betreff: [magnolia-user] Re: Language links to actual page (i18n)

     Hi,

     thanks for all the answers, you're helping me a lot! I'm actually trying 
to suggest this system for my university's web and I'm doing it as part of my 
diploma's thesis. But firstly I have to persuade them that this is a good 
system to migrate to :) So I will definetely need to sink into development env.

It's the best system! Definately! ;-) Let us know how we can help you convince 
them...

     So far I managed to setup dev env. (eclipse + tomcat + maven) according to 
the guides. (Only weird thing was that I couldnt find magnolia 4.5.3 in svn 
rep, only 4.5.2 and then 5). Anyway I started the application 
(magnolia-empty-webapp) and now I'm trying to learn to work with this env, but 
hit some major obstacles. Hopefully somebody can help me and point me in a good 
direction.

Magnolia has moved to GIT. There's a bunch of pages on the Wiki to help you get 
started with GIT, although the move can be a bit confusing at first if you are 
used to SVN, it isn't actually hard to do.

     1. How can I add modules (stk,...) to this webapp? And how can I add them 
to this maven project, so I can edit sources and after recompiling I will see 
changes in my webapp? I would like to have the same magnolia installation that 
comes as a download bundle, but I will be able to edit and debug sources. I 
managed to add magnolia-core (as a project = editable), but thats because it's 
already there, but i wasnt succesful with stk module.

     2. How can I then create jar files of modules (with my changes)?

Personally, I would try to get by without changing magnolia's code directly. 
You've probably looked at magnolia a little, and may have seen the (awesome) 
content2bean mechanism Magnolia uses to initialize much if its configuration. 
If you look in the config workspace, you will see a huge number of module and 
other configurations, often with "class" properties identifying the 
implementing class.
Additionally, Magnolia 4.5 has introduced components and dependency injection 
based on annotations.
What this means, or what I am getting at is that you can do almost anything in 
magnolia by extending existing classes, and reconfiguring the components or the 
content2bean configuration to use your extended classes. In this way you can 
add almost any functionality you want without ever modifying a line of 
magnolia's source code directly. Additionally, you can create your own modules 
to separate your functionality into cleanly deployable units. Magnolia's module 
mechanism is both flexible and powerful, while still being easy to use.
I think that working in this way has many advantages over changing magnolia's 
code directly. Most importantly, when upgrading you don't have to merge your 
changes with magnolia's. At most, you have to do a bit of refactoring to bring 
your extensions and modules in line with API changes.
The only real use-case I see for changing the magnolia code directly is if you 
want to fix bugs and give the code back to magnolia. In that case it makes 
sense to check out and modify their code directly.

     P.S. I'm still mainly trying to achieve to have Langauge switching links - 
I want to use the patch from Greg that makes them available in meta navigation 
area.
     P.P.S I have good knowledge of java,  subversion and a little of java ee 
and eclipse, but no knowledge of maven.

I've been developing magnolia modules for a few years now, and I still don't 
use maven. You don't really need it, unless you want to change magnolia's code 
itself and rebuild magnolia, but as noted above, I would not recommend that. I 
think it also depends on your project team. For a single developer (I'm the 
main java developer in our team, and I started out alone) or a small team, 
working with maven adds quite a bit of overhead and (my opinion, don't kill 
me!) slows you down.
You can work without maven:
- Download a Magnolia Bundle, and unpack it. Add all the JARs from 
webapps/magnoliaAuthor/WEB-INF/lib to your classpath.  This will supply all the 
dependencies you need to start coding your own modules.
- Look at the structure of a module by unpacking one of magnolia's module JARs. 
It's pretty straightforward. There's classes, and there's some resources stored 
in directories like "mgnl-bootstrap", "mgnl-resources". There's also a META-INF 
directory with the modules XML descriptor file in it.
- If you create the same structure as a Java project (in particular what you 
need is the "META-INF" directory with your modules descriptor file in it), and 
then export this Java Project as a JAR file, then hey-presto, you will have a 
perfectly functional magnolia module.
All without ever using maven.

In addition, I check out the magnolia code for the various parts I am extending 
in order to have the code to read as a reference. But for that I don't need to 
compile it, so I don't need maven there either...

Good luck with your development!

Regards from Vienna,

Richard

PS: Here is some pure freemarker code for implementing a language switcher. 
This code worked with magnolia 4.4, so it might need some adaptation in 
magnolia 4.5...

<ul>
  [#list model.parent.site.i18n.locales as loc]
  [#if !(content.hideActiveLanguage!false) || 
loc.language!=state.locale.language ]
    [#assign iconLoc=loc.language /]
    [#if loc.language="de"][#assign iconLoc="at" /][/#if]
    [#assign langLoc=loc /]
    [#if !(content.useNativeLanguage!false)][#assign langLoc=state.locale 
/][/#if]
    <a href="${contextPath + model.parent.siteRoot.@handle + "/" + loc.language 
+ page.@handle}"
    style="background: 
url('${contextPath}/.resources/riselfrz-templating-components/famfam-flags/${iconLoc}.png')
 no-repeat scroll left center transparent; padding-left:18px">
      ${loc.getDisplayLanguage(langLoc)}
    </a><br/>
  [/#if]
  [/#list]
</ul>

Some infos:
this script was part of a paragraph (component) that editors could include in 
the navigation. Therefore "model.parent" refers to the parent model of the 
component, which in our case is the model of the page. So if you embedded this 
directly in the page template, you could remove the "parent" and directly call 
"model.site".
"model.parent.site.i18n.locales" lists the locales configured for the site. 
That's an EE feature, I think. In CE you might need a different way to get at 
this list. Not sure, you'd have to try it out.
[#assign iconLoc=loc.language /] is used to display a flag. We downloaded the 
flags from here: http://www.famfamfam.com/lab/icons/flags/  We stored the flags 
in our own module, but you could also put them in DMS or elsewhere, adapting 
the URL accordingly, of course.
content.useNativeLanguage is a Boolean property which editors could set in the 
dialog for the language-switching component. Depending on whether you set this 
to true or false, the languages are written either as "English, German, French, 
etc..." (ie: in the current language) or as "English, Deutsch, Francais, ..." 
(ie. in the "target" language). You could just replace the 
"content.useNativeLanguage" with either true or false, if you don't need this 
to be configurable.
Same goes for "content.hideActiveLanguage" which controls whether the current 
language is included in the list, or not.

If you have any questions about this, let me know. If you get it working in 
magnolia 4.5, I'd be interested to know what changes were necessary...


Regards from Vienna,

Richard



     --
     Context is everything: 
http://forum.magnolia-cms.com/forum/thread.html?threadId=c63ffdf2-b53b-4a0d-a393-7bdcc7549c5d


     ----------------------------------------------------------------
     For list details, see 
http://www.magnolia-cms.com/community/mailing-lists.html
     Alternatively, use our forums: http://forum.magnolia-cms.com/
     To unsubscribe, E-mail to: 
<[email protected]<mailto:[email protected]>>
     ----------------------------------------------------------------





----------------------------------------------------------------
For list details, see http://www.magnolia-cms.com/community/mailing-lists.html
Alternatively, use our forums: http://forum.magnolia-cms.com/
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to