[opencms-dev] contentload solr

Daniel Seidel d.seidel at alkacon.com
Fri Feb 8 14:31:09 CET 2019


Hi,

I haven't looked at your code in detail. On first sight: Do not start 
the parameters with "?". There's a "&{createPath" that should be 
"${createPath".

But, going for an alternative you might use <cms:search>: 
https://documentation.opencms.org/opencms-documentation/demos/lists-and-detail-pages-ii/

Best, Daniel.

Am 07.02.19 um 18:08 schrieb Андрей Диканский:
>
> Hello!
>
> Can you help me with extractiong content from xml files with 
> contentload tag?
>
> I have a resource type Direction with following xsd:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
> elementFormDefault="qualified">
>
> <xsd:include schemaLocation="opencms://opencms-xmlcontent.xsd"/>
>
> <xsd:element name="Directions" type="OpenCmsDirections"/>
>
> <xsd:complexType name="OpenCmsDirections">
> <xsd:sequence>
> <xsd:element name="Direction" type="OpenCmsDirection" minOccurs="0" 
> maxOccurs="unbounded"/>
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:complexType name="OpenCmsDirection">
> <xsd:sequence>
> <xsd:element name="Title" type="OpenCmsString" />
> <xsd:element name="Text" type="OpenCmsHtml" />
> <xsd:element name="Image" type="OpenCmsVfsFile" />
> <xsd:element name="Link" type="OpenCmsVarLink" minOccurs="0" />
> </xsd:sequence>
> <xsd:attribute name="language" type="OpenCmsLocale" use="required"/>
> </xsd:complexType>
>
> <xsd:annotation>
> <xsd:appinfo>
> <mappings>
> <mapping element="Title" mapto="property:Title" />
> <mapping element="Title" mapto="urlName" />
> </mappings>
> <defaults>
> <default element="Title" value="Add a new title here" />
> <default element="Text" value="Add your text" />
> </defaults>
> <layouts>
> <layout element="Text" widget="HtmlWidget" 
> configuration="downloadgallery" />
> <layout element="Image" widget="ImageGalleryWidget" 
> configuration="{useformat:true}" />
> </layouts>
> <validationrules/>
> <relations/>
> <searchsettings containerPageOnly="true"/>
> </xsd:appinfo>
> </xsd:annotation>
>
> </xsd:schema>
>
> I also have /sites/OpenCMSTest/service/index.jsp :
>
> <%@page buffer="none" session="false" trimDirectiveWhitespaces="true" %>
> <%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
> <!doctype html>
> <html lang="ru">
>
> <head>
> <meta charset="utf-8">
> <meta name="viewport" content="width=device-width, initial-scale=1, 
> shrink-to-fit=no">
> <link 
> href="<cms:link>%(link.weak:/system/modules/my.template/resources/css/main.css</cms:link>" 
> rel="stylesheet" type="text/css">
> <title>Заголовок</title>
> </head>
>
> <body>
>
> <header>
> </header>
>
> <main>
> <%-- Define a Solr query --%>
> <c:set var="solrQuery">?fq=type:Direction&sort=lastmodified desc</c:set>
>
> <%-- Define a create path --%>
> <c:set var="createPath">/sites/OpenCMSTest/.content/Direction/</c:set>
>
> <%-- Collect the resources --%>
> <cms:contentload collector="byContext" 
> param="${solrQuery}|createPath=&{createPath}" preload="true" >
>
> <c:if test='${info.resultSize != 0}'>
> <cms:contentinfo var="info" />
> <c:if test='${info.resultSize != 0}'>
> <h3>Search results </h3>
> <cms:contentload editable="false">
> <cms:contentaccess var="content" />
> ${content.Title} <br />
> </cms:contentload>
> </c:if>
> </c:if>
> </cms:contentload>
>
>
> </main>
>
> <footer>
> </footer>
>
>
> </body>
> </html>
>
> Also I have 3 file xml files (Direction-00001.xml, 
> Direction-00002.xml, Direction-00003.xml) with content 
> in /sites/OpenCMSTest/.content/Direction/ (see the attachment)
>
> When opeining  /sites/OpenCMSTest/service/index.jsp  I'd like to 
> extract Titles from xml files an show it in html.
>
> But nothing happens. It seems that there are no search results.
>
> What I'm doing wrong?
>
>
>
>
>
>
>
>
> -- 
> Andrew
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>
-- 
Kind Regards,
Daniel.
  
-------------------

Daniel Seidel

Alkacon Software GmbH & Co. KG - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20190208/99b951f2/attachment.htm>


More information about the opencms-dev mailing list