RE: How can I get link to document in web content with resource importer?

thumbnail
Vitaliy Koshelenko, modified 6 Years ago. Expert Posts: 319 Join Date: 3/25/11 Recent Posts
Hi emoticon 

I use resource importer to import pages/content together with theme (LR 7.1).
And I have web content, structure and template. Structure has image and text.
How can I tell web content to use image as document library document  (uploaded also with resource importer)? 

When I add image later and check web content, content is:
<root available-locales="en_US" default-locale="en_US">
&nbsp; &nbsp; <dynamic-element name="bannerImage" type="image" index-type="text" instance-id="jbml">
&nbsp; &nbsp; &nbsp; &nbsp; <dynamic-content language-id="en_US">
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "classPK":"35922",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "groupId":"35902",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "name":"home-banner-image.jpg",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "alt":"",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "title":"home-banner-image.jpg",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "type":"document",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "uuid":"ba0b3c4c-c580-fbe0-5b27-d1e4aede36b4",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "fileEntryId":"35922",
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "resourcePrimKey":"36045"
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</dynamic-content>
&nbsp; &nbsp; </dynamic-element>
&nbsp; &nbsp; <dynamic-element name="bannerText" type="text" index-type="keyword" instance-id="asun">
&nbsp; &nbsp; &nbsp; &nbsp; <dynamic-content language-id="en_US">Home Banner Text</dynamic-content>
&nbsp; &nbsp; </dynamic-element>
</root>

(with generated IDs inside for document)But I can't just hard-code IDs emoticon

If I define only document name in themes/my-theme/src/WEB-INF/src/resources-importer/journal/articles/home-banner/home-banner.xml, like:
<dynamic-content language-id="en_US"> "home-banner-image.jpg"</dynamic-content> 
it also does not work.

Is it possible to specify link to document in web content with resource importer? (in my case from file  [my-theme]/src/WEB-INF/src/resources-importer/journal/articles/home-banner/home-banner.xml to [my-theme]/src/WEB-INF/src/resources-importer/document_library/documents/home-banner-image.jpg )
Any help appreciated emoticon

Regards,
Vitaliy
thumbnail
Vitaliy Koshelenko, modified 6 Years ago. Expert Posts: 319 Join Date: 3/25/11 Recent Posts
Update:

Finally, I have encountered this issue:

https://liferay.dev/forums/-/message_boards/message/111978556#_com_liferay_message_boards_web_portlet_MBPortlet_message_112044826

If I use link to document like:

<dynamic-content>[$FILE=myfile.png$]</dynamic-content>

web content is processed by resource importer, and $FILE is replaced with link for example:

<dynamic-content>
<![CDATA[/documents/39002/0/myfile.png/13db6d1d-e438-620a-4873-825b48fe9d4e?version=1.0&t=1562307406201]]>
</dynamic-content>

and web content is saved.

But when I try to open/edit this web content - it fails, because it expects JSON instead of link.

Any ideas?
thumbnail
Aravinth Kumar, modified 5 Years ago. Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
Hi Guys, Did anyone find solution for this issue?
Regards,Aravinth
thumbnail
Aravinth Kumar, modified 5 Years ago. Regular Member Posts: 152 Join Date: 6/26/13 Recent Posts
As of now I achieved it through,  I created both text box and document image type fields in structure and added condition in the template to manage based on the condition. 
 &lt;#if Image.getData()?? &amp;&amp; Image.getData() != ""&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;#assign imgSrcVal = Image.getData()/&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &lt;#else&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;#assign imgSrcVal = resourceImporterImage.getData()/&gt;
&nbsp; &nbsp; &nbsp; &nbsp; <!--#if-->
&nbsp; &nbsp; <img src="${imgSrcVal}">