Foros de discusión

web content structures not working

thumbnail
domingo l hilario, modificado hace 14 años.

web content structures not working

Junior Member Mensajes: 46 Fecha de incorporación: 5/02/09 Mensajes recientes
Hello guys, I have a question, I added a new template and structure but the when i create the structure it doesn't show but the text only

for instance if I type : $main-text.getData() when I preview it I will get the same thing just the variable $main-text.getData().
I have also tried the $title.getData() and other vm instruction found on liferay portal but none of them are working. I need some help with this one.

I am trying to create a template and structure where the user can attached documents to the story from the document library. I have created the template but their is not enough documentation about how to set up a web content structure.


## Velocity Transform Template
##
## All dynamic elements in a structure can be accessed as a Velocity variable.
##
## The given structure:
##
<root>
<dynamic-element name="main-text" type="text_area">
<dynamic-element name="sub-image" type="image"></dynamic-element>
<dynamic-element name="sub-text" type="text">$status.getData()<dynamic-element>
</dynamic-element>

<dynamic-element name="more-text" type="text_area"></dynamic-element>
<dynamic-element name="ms-list" type="multi-list">
<dynamic-element name="chocolate" type="Chocolate"></dynamic-element>
<dynamic-element name="strawberry" type="Strawberry"></dynamic-element>
<dynamic-element name="vanilla" type="Vanilla"></dynamic-element>
</dynamic-element>
</root>



## The dynamic element "main-text" can be accessed in the following ways:
##
## $main-text.getName() - The name "main-text"
##$main-text.getData() - The data in the article for main-text
## $main-text.getType() - The type "text-area"
##$main-text.getChildren() - A collection with two nodes (sub-image and
## sub-text) that can be used in the #foreach clause
##
## One special accessor exists for elements of type "multi-list":
##
## $ms-list.getOptions() - A collection with up to three string entries
## (chocolate, strawberry, or vanilla) that can be used
## in the #foreach clause
##
## Another special accessor exists for elements of type "link_to_layout":
##
## $linkToPage.getUrl() - The URL that links to the selected page in the current
## community, organization, etc.
##
## Additionally, the variable $journalTemplatesPath can be used to include
## another Journal template, e.g. #parse ("$journalTemplatesPath/LAYOUT-PARENT")
##


i will greatly appreciate any help I can get. Thanks
Sverker Abrahamsson, modificado hace 14 años.

RE: web content structures not working

New Member Mensajes: 13 Fecha de incorporación: 3/04/08 Mensajes recientes
Hi
I'm stuck on the same issue. Did you find a solution?

There is also a bug report which I believe is related: http://issues.liferay.com/browse/LPS-3740
thumbnail
domingo l hilario, modificado hace 14 años.

RE: web content structures not working

Junior Member Mensajes: 46 Fecha de incorporación: 5/02/09 Mensajes recientes
I have found my issue

when you add a new structure we have to look at it as variable names. for instance

title : text(html)



then under the template you have to use the name or for the text box on which I have name title

then to get the data you type as

$title.getData()

do not use semi colon to close the statement because it will appear on the page as garbage.

if you would like to do an if (){} statement then you can write it as.



## This will display the statement if the statement is not empty

#if( ! $title.getData().equals('') )
$title.getData()
#end



you can add more rows at a later point. when you are creating the template you can use html to style your page. you can use either div or tables and you can style the page with css.
thumbnail
Olaf Kock, modificado hace 14 años.

RE: web content structures not working

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
The upper part of your code example provides the structure:
## Velocity Transform Template
##
## All dynamic elements in a structure can be accessed as a Velocity variable.
##
## The given structure:
##
<root>
<dynamic-element name="main-text" type="text_area">
<dynamic-element name="sub-image" type="image"></dynamic-element>
<dynamic-element name="sub-text" type="text">$status.getData()<dynamic-element>
</dynamic-element>
<dynamic-element name="more-text" type="text_area"></dynamic-element>
<dynamic-element name="ms-list" type="multi-list">
<dynamic-element name="chocolate" type="Chocolate"></dynamic-element>
<dynamic-element name="strawberry" type="Strawberry"></dynamic-element>
<dynamic-element name="vanilla" type="Vanilla"></dynamic-element>
</dynamic-element>
</dynamic-element></dynamic-element></root>


There are some strange things in this - namely the lines

<dynamic-element name="sub-text" type="text">$status.getData()<dynamic-element>
</dynamic-element>
</dynamic-element>


This seems to mix a structure and a template. I believe
<dynamic-element name="sub-text" type="text"></dynamic-element>
is what you want instead, giving (with additional indenting)


<root>
    <dynamic-element name="main-text" type="text_area">
    <dynamic-element name="sub-image" type="image"></dynamic-element>
    <dynamic-element name="sub-text" type="text">
        <dynamic-element name="more-text" type="text_area"></dynamic-element>
        <dynamic-element name="ms-list" type="multi-list">
        <dynamic-element name="chocolate" type="Chocolate"></dynamic-element>
        <dynamic-element name="strawberry" type="Strawberry"></dynamic-element>
        <dynamic-element name="vanilla" type="Vanilla"></dynamic-element>
    </dynamic-element>
</dynamic-element></dynamic-element></root>


This defines that you are able to access the following velocity elements in your template:

  • $main-text
  • $sub-image
  • $sub-text
  • $sub-text.more-text
  • $sub-text.ms-list
  • $sub-text.chocolate
  • $sub-text.strawberry
  • $sub-text.vanilla

All of these can be followed by .getData() to get the content. I suppose you wanted the nested content - right?

There are some more elements that are available (namely $reserved-article-XXXXX as documented in this Wiki article.

For the purpose of preserving your example I've left the chocolate (etc) elements in, but note that liferay does not support chocolate, strawberry and vanilla out of the box - at least not as element types for structure elements (type="Chocolate") - you're free to name your elements this way though. ;-)