Jahia Dev Forum > Help to build a...

0 (0 Good)
0 (0 Bad)

Help to build a module

by  giandrea »  2011/11/22 09:42

Hi all,

I'm newbie in Jahia and I need to create a module. I'm looking for a tutorial or a simple module to understand how to create a new module in Jahia. Where can I found that kind of documentation? 

 could you help me, please?

king regards!

Andrea

  (giandrea)

Number of messages  2
Registration date
0 (0 Good)
0 (0 Bad)

Re: Help to build a module

by  theklem »  2011/11/22 10:08

Hi Andrea,

you should have a look at the templating guide it explains the main jahia concepts (modules, views, definitions, templates...) and also the steps to create new modules.

http://www.jahia.com/cms/home/community/documentation/templating-and-integration-guide.html

If you have a java environment already setup (eclipse or intellij, maven, etc) you can use a maven script to create your module structure. If you just want to test simple things without a complete environment you can do things with a simple text editor, this are the basic steps

 

create a folder "mymodule"

create a subfolder "META-INF"

create a text file "MANIFEST.MF"

put in the manifest the following with your own values

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Andrea
Build-Jdk: 1.6.0_22
Implementation-Title: a name
Implementation-URL: 
Implementation-Vendor: 
Implementation-Vendor-Id: 
Implementation-Version: 1.0-SNAPSHOT
Specification-Title: yourModuleName
Specification-Vendor: 
Specification-Version: 1.0-SNAPSHOT
depends: Default Jahia Templates
package-name: yourModuleName
root-folder: yourModuleName
 
The module does nothing at this stage obviously but can be deployed and recongnized correctly by Jahi.a. To do that zip your module folder (mymodule.zip) and renaming it as mymodule.war.
You can put this war into the shared-modules directory (if you've downloaded a version of Jahia it should be in \tomcat\webapps\ROOT\WEB-INF\var\shared_modules) and thyat's it after a few seconds Jahia will deploy the module in \tomcat\webapps\ROOT\modules\

Now it's up to you to define what this new module does and create the folders and scripts you need.
If your module, for instance just defines a new content type, you'll have to create a definition file and some rendering scripts
Your module can contain rules, classes, spring files, jbpm workflow files... the subject is too large to give you more info here.

Note : you should really prefer the maven module creation procedure than a hand-made solution if you have a bit of java development experience. By hand, it's very easy to make some errors in the manifest.

  • Re: Help to build a module
    2011/11/22 10:08

    theklem <p> Hi Andrea,</p> <p> you should have a look at the templating guide it explains the main jahia concepts (modules, views, definitions, templates...) and also the steps to create new modules.</p> <p> <a href="http://www.jahia.com/cms/home/community/documentation/templating-and-integration-guide.html">http://www.jahia.com/cms/home/community/documentation/templating-and-integration-guide.html</a></p> <p> If you have a java environment already setup (eclipse or intellij, maven, etc) you can use a maven script to create your module structure. If you just want to test simple things without a complete environment you can do things with a simple text editor, this are the basic steps</p> <p> &nbsp;</p> <p> create a folder &quot;mymodule&quot;</p> <p> create a subfolder &quot;META-INF&quot;</p> <p> create a text file &quot;MANIFEST.MF&quot;</p> <p> put in the manifest the following with your own values</p> <div> Manifest-Version: 1.0</div> <div> Archiver-Version: Plexus Archiver</div> <div> Created-By: Apache Maven</div> <div> Built-By: Andrea</div> <div> Build-Jdk: 1.6.0_22</div> <div> Implementation-Title: a name</div> <div> Implementation-URL:&nbsp;</div> <div> Implementation-Vendor:&nbsp;</div> <div> Implementation-Vendor-Id:&nbsp;</div> <div> Implementation-Version: 1.0-SNAPSHOT</div> <div> Specification-Title: yourModuleName</div> <div> Specification-Vendor:&nbsp;</div> <div> Specification-Version: 1.0-SNAPSHOT</div> <div> depends: Default Jahia Templates</div> <div> package-name: yourModuleName</div> <div> root-folder: yourModuleName</div> <div> &nbsp;</div> <div> The module does nothing at this stage obviously but can be deployed and recongnized correctly by Jahi.a. To do that zip your module folder (mymodule.zip) and renaming it as mymodule.war.</div> <div> You can put this war into the shared-modules directory (if you&#39;ve downloaded a version of Jahia it should be in&nbsp;\tomcat\webapps\ROOT\WEB-INF\var\shared_modules) and thyat&#39;s it after a few seconds Jahia will deploy the module in&nbsp;\tomcat\webapps\ROOT\modules\</div> <p> Now it&#39;s up to you to define what this new module does and create the folders and scripts you need.<br /> If your module, for instance just defines a new content type, you&#39;ll have to create a definition file and some rendering scripts<br /> Your module can contain rules, classes, spring files, jbpm workflow files... the subject is too large to give you more info here.<br /> <br /> Note : you should really prefer the maven module creation procedure than a hand-made solution if you have a bit of java development experience. By hand, it&#39;s very easy to make some errors in the manifest.</p>

  • Number of messages  85
    Registration date Nov 22, 2011
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Help to build a module

    by  giandrea »  2011/11/22 17:01

     

    Hi Clement

    thanks for your reply!

    I tried and it works but, when I try to add a module with a simple jsp (just <h1>TEST</h1>) on Jahia Studio I get this error message:

    no render set for node : mymodule

    for types : [jnt:myModule, jmix:accessControlled]

    I created a folder called jnt_mymodule\html that contains a myModule.jsp file

    On log I get 

    ERROR [ContentManagerHelper] - Exception

    javax.jcr.nodetype.ConstraintViolationException: Couldn't find definition for property j:view
     
    I don't understand where I've to declare the view.
     
    This is my definitions.cnd file:

    <jnt = 'http://www.jahia.org/jahia/nt/1.0'>

    <jmix = 'http://www.jahia.org/jahia/mix/1.0'>

    [jnt:myModule] > jnt:content, jmix:siteComponent

     
    what's wrong?
     
    Andrea

     

      (giandrea)

    Number of messages  2
    Registration date
    0 (0 Good)
    0 (0 Bad)

    Re: Re: Re: Help to build a module

    by  rvt »  2011/11/24 14:42

    Andrea,

    the only think I can see you did wrong is that you called the directory jnt_mymodule instead of jnt_myModule (note the captial M).

    Ries

     

  • Re: Re: Re: Help to build a module
    2011/11/24 14:42

    rvt <p> Andrea,</p> <p> the only think I can see you did wrong is that you called the directory&nbsp;jnt_my<strong>m</strong>odule instead of&nbsp;jnt_my<strong>M</strong>odule (note the captial <strong>M</strong>).</p> <p> Ries</p> <p> &nbsp;</p>

  • Number of messages  185
    Registration date Nov 24, 2011
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page