What is Document Type ?
Hippo CMS maintains a strict separation of content and presentation. Content is stored in documents. These documents have a clearly defined structure, making it very easy for editors to work with. The separation makes it easy for editors to work on the actual content. No HTML knowledge is required and, best of all, you can reuse the content anywhere.
What is Document ?
Document is the drop down in the top left corner and add a new document to the project. Document provides URL name in the field below. It uses the name to create a URL friendly version of that document editor interface containing the fields we configure for this document type.
Step 1. create document type.
Step 2. create string filed.
Add a String field (Primitive) for our title and set the Caption to Title and Path to title. Next, add a Rich Text Editor (Compound Field) to the document type. Set the Caption to Content and the path to content. After adding the fields, click ‘Done’ and then select ‘Type Actions’, ‘Commit’. The document type is now ready for use in the CMS.
Step 3. create a document.
Select ‘Documents’ from the dropdown in the top left corner and add a new document to the myhippoprojectfolder.
Name the document Hello World. Also, note the URL name in the field below. It uses the name to create a URL friendly version of the document, which is used as the filename. After you click OK, you will be presented with the document editor interface containing the fields we configured for this document type.
Enter some text in the document fields and click ‘Save & Close’. Then click on the ‘Publish’ option in the ‘Publication’ menu so the document becomes available to the site.
Step 4. create a model.
select radio button either freemarker or ftl file.
Select Tools in left menu then click Use bean writer then click “Generate HST Content beans” button.
After that bean will be generate.
step 5 :Create a Controller
With the model in place (the content bean wrapping the content), you can now create a controller and implement the business logic to retrieve the content bean and make it available to the view. In Hippo’s delivery tier, controllers are implemented as Java components.
There is just one method in the class, the doBeforeRender method. This method is called just before the view is rendered, and its purpose is to perform any business logic and prepare any data that is required to render the view.
Step 6 : Make the view Dynamic
You now have a model and a controller which retrieves it and stores it in a request attribute. Now you can modify your Freemarker template to make the view dynamically render the content wrapped by the model.
In addition to the regular Freemarker syntax and expressions, you can use Hippo-specific tags from theHST tag library. An example in the template above is the <@hst.html> tag. This tag will process the data contained in the Rich Text field, ensuring that all internal links are validated and rewritten to the correct URL in the current page context.
mvn verify mvn -Pcargo.run
Step 6: Configure the MVC Component
After the build is done, go back to the Console to add the newly created
/hst:hst/hst:configurations/myhippoproject/hst:components + simplecomponent [hst:component] - hst:componentclassname = org.example.components.SimpleComponent
Step 7: Map the URL to the Content
/hst:hst/hst:configurations/myhippoproject/hst:sitemap/root - hst:componentconfigurationid = hst:pages/home - hst:relativecontentpath = hello-world
- Topics:Hippo CMS