[opencms-dev] contentload solr
Андрей Диканский
andikk at mail.ru
Thu Feb 7 18:08:45 CET 2019
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20190207/c1e87839/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.jpg
Type: image/jpeg
Size: 77418 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20190207/c1e87839/attachment.jpg>
More information about the opencms-dev
mailing list