Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Malek Tarboush
Customize Asset Publisher , Structure , Template
28 settembre 2010 5.46
Risposta

Malek Tarboush

Punteggio: Junior Member

Messaggi: 30

Data di Iscrizione: 19 settembre 2010

Messaggi recenti

Hello all
I'm trying to customize AssetPublisher style that show only web contents
with a custom structure and custom template
i was able to get everything from AssetEntry and AssetRenderer
its ok until now it works fine
but the problem is that
how can i get the additional parameters that i added in the customized structure?

my structure is something like this
1
2<root>
3 <dynamic-element name='right_image' type='image' index-type='' repeatable='false'>
4</dynamic-element>
5  <dynamic-element name='left_image' type='image' index-type='' repeatable='false'>
6</dynamic-element>
7</root>


so there is a new elements for every Journal Article

but how can i get these new elements from inside a JSP page
( AssetPublisher new display style )??

anyone has any idea about that

thanks
Malek Tarboush
RE: Customize Asset Publisher , Structure , Template
4 ottobre 2010 5.58
Risposta

Malek Tarboush

Punteggio: Junior Member

Messaggi: 30

Data di Iscrizione: 19 settembre 2010

Messaggi recenti

from the JournalArticle I can get the structure id etc..

and this AssetEntry which i can get in AssetPublisher is originally a JournalArticle
but when I'm trying to cast from AssetEntry to JournalArticle
it throws cast exception may be because the AssetPublisher
wrap the JournalArticle in new Object (AssetEntry )

so is there anyway to get the AssetEntry as JournalArticle inside the AssetPublisher page?
so i can get the structure of this specific JournalArticle



thanks
Malek Tarboush
RE: Customize Asset Publisher , Structure , Template
5 ottobre 2010 5.56
Risposta

Malek Tarboush

Punteggio: Junior Member

Messaggi: 30

Data di Iscrizione: 19 settembre 2010

Messaggi recenti

Ok I'll answer myselfemoticon

I got something good but not enough
from the asset entry now I'm able to get the original article (JournalArticle)
and the journal article my custom template and structure

and this is the way
this code exist in a custom AssetPublisher style called mine

mine.jsp ( it just show the code i added to )
 1
 2JournalArticle ja = null;
 3JournalStructure js = null;
 4JournalTemplate jt = null;
 5
 6JournalArticle  = JournalArticleLocalServiceUtil.getLatestArticle(assetEntry.getClassPK());
 7
 8try {
 9
10if (ja.getStructureId() != null && !ja.getStructureId().trim().equals("")) {
11
12js = JournalStructureLocalServiceUtil.getStructure(ja.getGroupId(),ja.getStructureId());
13
14}
15
16if (ja.getTemplateId() != null && !ja.getTemplateId().trim().equals("")) {
17
18jt = JournalTemplateLocalServiceUtil.getTemplate(ja.getGroupId(), ja.getTemplateId());
19
20}
21
22} catch (PortalException e) {
23e.printStackTrace();
24} catch (SystemException e) {
25e.printStackTrace();
26}


but also my problem did not end
because the problem that i can't get the variable values that i added in the custom strucure and custom template

I print the xsl data in the template object and the structure variable names there
but i want the value of these variables

any idea ?

I will keep trying
Balazs Pinter
RE: Customize Asset Publisher , Structure , Template
25 luglio 2011 16.32
Risposta

Balazs Pinter

Punteggio: New Member

Messaggi: 4

Data di Iscrizione: 25 luglio 2011

Messaggi recenti

Hi.

Did you figure out how can you solve this issue? I would appreciate it if you share your code.
Manali Lalaji
RE: Customize Asset Publisher , Structure , Template
26 luglio 2011 0.18
Risposta

Manali Lalaji

Punteggio: Expert

Messaggi: 362

Data di Iscrizione: 9 marzo 2010

Messaggi recenti

Hi Malek,
You can try the sample code : Call the function getArticleFieldValue() which returns specific value for template

Document document = null;
JournalArticle authorJournalArticle=null;
content = journalArticle.getContent();
try {
document = SAXReaderUtil.read(new StringReader(content));
} catch (DocumentException e1) {
_log.warn("DocumentException : "+e1.getMessage());
}

if(Validator.isNotNull(document)){
imageUrl = getArticleFieldValue(document, "IMAGE");
status = getArticleFieldValue(document, "STATUS");
}

public static String getArticleFieldValue(Document document,String field){
String retValue = "";
if (Validator.isNotNull(document)) {
Node fieldContent = document.selectSingleNode("/root/dynamic-element[@name='"+field+"']/dynamic-content");
if(fieldContent!=null){
retValue = fieldContent.getText();
}
}
return retValue;
}

Hope this helps,

Thanks,
Manali
Judith Sambs
RE: Customize Asset Publisher , Structure , Template
23 gennaio 2013 7.38
Risposta

Judith Sambs

Punteggio: New Member

Messaggi: 13

Data di Iscrizione: 3 dicembre 2012

Messaggi recenti

While reading this post some questions arise in my head:
  • where should I put your code pieces?
  • are JournalArticleLocalServiceUtil and SAXReaderUtil available anyway or do I have to include it somehow
  • what datatype does "content" have?
  • is that code valid for Liferay Portal Community Edition 6.1.1 CE GA2

I am a liferay beginner and although I've been searching the web for days now I still could not access fields defined in the article's structure with the asset publisher. Either I don't know HOW to apply the solution or it doesn't work. I am grateful for any kind of help!

Thank you!
Claire Attard
RE: Customize Asset Publisher , Structure , Template
19 novembre 2013 8.32
Risposta

Claire Attard

Punteggio: New Member

Messaggi: 3

Data di Iscrizione: 19 dicembre 2012

Messaggi recenti

Hi,

I am currently on an asset publisher in version 6.2 and i would like to create a custom vm template to display information from a web content structure. As i can understand it i can only use the variables of the asset entry but i would like to also like to include variables from the actual asset entry structure. is this possible using the ADT? I've seen the post explaining how this could be done in version 6.1 on your post, however i'm not sure if this will work in version 6.2.

Any feedback/ ideas would be appreciate