I need to be able to search by the News Tags property.
This typoscript is working fine, but when I input a tag (exact same string) from a News into Solr's search box I don't get any results.
According to "lorenz" in this answer I neede to add my dynamic fields (I believe) to "plugin.tx_solr.query.fields" but this poor documentation doesn't help me.
I added the following to that typoscript but when I use the searchbox to look for exactly the name of my tag I get no results.
(plugin.tx_solr.query.fields = tags_stringM)
Does anybody have any code that I can use as an example?
plugin.tx_solr{
search {
initializeWithEmptyQuery = 1
showResultsOfInitialEmptyQuery = 1
showEmptyFacets = 1
faceting = 1
faceting {
facets {
mediatype {
label = Facet dos
field = categorytitle_stringS
}
}
}
}
index.queue {
custom_news = 1
custom_news {
table = tx_news_domain_model_news
fields {
abstract = teaser
author = author
authorEmail_stringS = author_email
title = title
datetime_stringS = TEXT
datetime_stringS {
field = datetime
date = d.m.Y H:i
}
titlehr_stringS = TEXT
titlehr_stringS {
field = title_hr
}
teaser_stringS = TEXT
teaser_stringS {
field = teaser
}
datetime_dateS = TEXT
datetime_dateS {
field = datetime
date = Y-m-d\TH:i:s\Z
}
content = SOLR_CONTENT
content {
cObject = COA
cObject {
10 = TEXT
10 {
field = bodytext
noTrimWrap = || |
}
20 = TEXT
20 {
field = tags_stringM
noTrimWrap = || |
}
}
}
categorytitle_stringS = SOLR_RELATION
categorytitle_stringS {
localField = categories
multiValue = 1
}
categoryuid_stringS = SOLR_RELATION
categoryuid_stringS {
localField = categories
foreignLabelField = uid
multiValue = 1
}
keywords = SOLR_MULTIVALUE
keywords {
field = keywords
}
tags_stringM = SOLR_RELATION
tags_stringM {
localField = tags
label = Tags
multiValue = 1
}
tagshr_stringM = SOLR_RELATION
tagshr_stringM {
localField = tags
label = Tags hr
foreignLabelField = title_hr
multiValue = 1
}
mediatypehr_intS = TEXT
mediatypehr_intS {
field = media_type_hr
}
mediatypede_intS = TEXT
mediatypede_intS {
field = media_type_de
}
image_stringS = FILES
image_stringS {
references {
table = tx_news_domain_model_news
uid.field = uid
fieldName = fal_media
}
begin = 0
maxItems = 1
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
file.maxW = 330
#wrap = |
}
}
url = CASE
url {
key.field = type
# Internal
1 = TEXT
1 {
if.isTrue.field = internalurl
typolink.parameter.field = internalurl
typolink.useCacheHash = 1
typolink.returnLast = url
}
# External
2 = TEXT
2 {
if.isTrue.field = externalurl
field = externalurl
}
default = TEXT
default {
typolink.parameter = {$plugin.tx_news.settings.detailPid}
typolink.additionalParams = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]={field:uid}&L={field:__solr_index_language}
typolink.additionalParams.insertData = 1
typolink.useCacheHash = 1
typolink.returnLast = url
}
}
}
attachments = 1
attachments {
fields = fal_related_files
fileExtensions = *
}
}
}
}
plugin.tx_solr.logging.indexing.queue.news = 1
Aside from defining the fields for indexing you also need to declare these fields as relevant for search. (and with a weight how important they are for searching)
One possible solution could be like in this part of typoscript:
plugin {
tx_solr {
search {
query {
queryFields := addToList(categorytitle_stringS^2.0,keywords2.0,tags_stringM^2.0, tagshr_stringM^2.0)
}
}
}
}
see manual
[TYPO3 8.7, ext_solr 9.0]
I have a custom extension for events. Solr should index the field startdate but doesn't. Everything else works fine.
plugin.tx_solr.index.queue {
events = 1
events {
table = tx_customevents_domain_model_event
fields {
title = title
abstract = teaser
startdate_intS = startdate
content = SOLR_CONTENT
content {
field = bodytext
}
url = TEXT
url {
typolink {
parameter = {$plugin.tx_customevents_list.settings.singelePid}
additionalParams = &tx_customevents_list[event]={field:uid}&tx_customevents_list[action]=show&tx_customevents_list[controller]=Event
additionalParams.insertData = 1
returnLast = url
useCacheHash = 1
}
}
}
}
}
plugin.tx_solr.search.query.queryFields := addToList(startdate_intS^1.0)
The Fluid debugger does not show it in the resultSet object, even after having emptied the index queue.
What am I missing here?
I setup a TYPO3 v.9 website with solr.
And for some reason, the Pages indexer not working. So I used the custom TS configuration bellow, to work around and to force Pages indexing. With this custom TS, pages was indexed, BUT the links to a Page from the "Search results" is not working.
This is my custom TS :
#TS added to force page indexing
plugin.tx_solr.index.queue {
snar_pages = 1
snar_pages {
table = pages
fields {
title = title
content = SOLR_CONTENT
content {
cObject = COA
cObject {
10 = TEXT
10 {
field = bodytext
noTrimWrap = || |
}
}
}
url = CASE
url {
key.field = type
# Internal
1 = TEXT
1 {
if.isTrue.field = internalurl
typolink.parameter.field = internalurl
typolink.useCacheHash = 1
typolink.returnLast = url
}
# External
2 = TEXT
2 {
if.isTrue.field = externalurl
field = externalurl
}
default = TEXT
default {
typolink.parameter = {link}
typolink.additionalParams >
typolink.useCacheHash = 1
typolink.returnLast = url
}
}
}
}
is there an error in my TS that prevents the links to the pages from working ?
hmm i think you missed something to setup too for indexing pages. The DataFrontendHelper
see the docs
edited:
plugin.tx_solr {
index {
queue {
pages {
indexer {
frontendDataHelper {
host = {$plugin.tx_solr.indexer.frontendDataHandler.host}
scheme = {$plugin.tx_solr.indexer.frontendDataHandler.scheme}
}
}
}
}
}
}
Changing my TS as follows, and this fixed my problem :
url = CASE
url {
key.field = doktype
default = TEXT
default {
field = title
typolink.parameter.field = uid
typolink.returnLast = url
}
PS : pages need to be re-indexed for good results.
I got a website to move to our server and I have successfully moved it.But I have noticed some strange thing.Site doesn't render Danish characters (only special characters).When when I try to save using htmlarea in admin section and I can save Lorem Ipsum with any issue.But special danish characters are seems saving to database but when I open htmlarea it shows nothing.
Seems me there should be some configuration or settings to do.I tried to change character set but didnt work.Then whole db and table change to Utf8.No luck.
Anyone is having an idea to fix this?
please mentioned the place and page name as I am totally newbie to typo3
Thanks
More info regarding typo3 ond utf8 you can find there - http://wiki.typo3.org/UTF-8_support (TYPO3 UTF-8 support). Which TYPO3 version you have?
I think you have to modify your page typoscript configuration.
set htmlSpecialChars = 0 at the time of both entryHTMLparser_db and exitHTMLparser_db.
Use below page typoscript configuration. Might be your problem will be solved.
mod.SHARED {
defaultLanguageFlag = de
defaultLanguageLabel = Deutsch
}
# Classes. Do not forget to define them in the CSS class
RTE.classes {
# lists
checklist {
name = Checkliste
}
# tables
table {
name = Normale Tabelle
}
table-condensed {
name = Verkürzte Tabelle
}
table-bordered {
name = Tabelle mit Rahmen
}
table-styled {
name = Tabelle mit anderem Design
}
table-striped {
name = Tabelle mit Streifen
}
table-hover {
name = Tabelle mit Hover-Effekt
}
# aligns
align-justify {
name = LLL:EXT:rtehtmlarea/htmlarea/locallang_tooltips.xml:justifyfull
}
align-left {
name = LLL:EXT:rtehtmlarea/htmlarea/locallang_tooltips.xml:justifyleft
value = text-align: left;
}
align-center {
name = LLL:EXT:rtehtmlarea/htmlarea/locallang_tooltips.xml:justifycenter
value = text-align: center;
}
align-right {
name = LLL:EXT:rtehtmlarea/htmlarea/locallang_tooltips.xml:justifyright
value = text-align: right;
}
csc-frame-frame1 {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:frame-frame1
value = background-color: #EDEBF1; border: 1px solid #333333;
}
csc-frame-frame2 {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:frame-frame2
value = background-color: #F5FFAA; border: 1px solid #333333;
}
important {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:important
value = color: #8A0020;
}
name-of-person {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:name-of-person
value = color: #10007B;
}
detail {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:detail
value = color: #186900;
}
component-items {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:component-items
value = color: #186900;
}
action-items {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:action-items
value = color: #8A0020;
}
component-items-ordered {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:component-items
value = color: #186900;
}
action-items-ordered {
name = LLL:EXT:rtehtmlarea/res/contentcss/locallang.xml:action-items
value = color: #8A0020;
}
style1 {
name = Stil 1
}
htmlCode {
name = HTML Code
}
phpCode {
name = PHP Code
}
}
RTE.classesAnchor {
externalLink {
class = external-link
type = url
titleText = LLL:EXT:rtehtmlarea/res/accessibilityicons/locallang.xml:external_link_titleText
}
externalLinkInNewWindow {
class = external-link-new-window
type = url
titleText = LLL:EXT:rtehtmlarea/res/accessibilityicons/locallang.xml:external_link_new_window_titleText
}
internalLink {
class = internal-link
type = page
titleText = LLL:EXT:rtehtmlarea/res/accessibilityicons/locallang.xml:internal_link_titleText
}
internalLinkInNewWindow {
class = internal-link-new-window
type = page
titleText = LLL:EXT:rtehtmlarea/res/accessibilityicons/locallang.xml:internal_link_new_window_titleText
}
download {
class = download
type = file
titleText = LLL:EXT:rtehtmlarea/res/accessibilityicons/locallang.xml:download_titleText
}
mail {
class = mail
type = mail
titleText = LLL:EXT:rtehtmlarea/res/accessibilityicons/locallang.xml:mail_titleText
}
more-link {
class = more-link
type = page
titleText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:more_link_titleText
altText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:more_link_altText
}
button-link {
class = btn
type = page
titleText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:more_link_titleText
altText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:more_link_altText
}
next-link {
class = ym-button ym-next
type = page
titleText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:next_link_titleText
altText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:next_link_altText
}
back-link {
class = back-link
type = page
titleText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:back_link_titleText
altText = LLL:EXT:fluxtemplate/Resources/Private/Language/locallang.xml:back_link_altText
}
}
RTE.default {
showButtons = *
## Enable the image button
showButtons := addToList(image)
defaultContentLanguage = de
// Make possible to read classes from the contentCSS CSS file
buttons.textstyle.tags.span.allowedClasses >
buttons.textstyle.tags.REInlineTags >
buttons.textstyle.REInlineTags >
buttons.blockstyle.tags.table.allowedClasses >
buttons.blockstyle.tags.p.allowedClasses >
buttons.blockstyle.tags.div.allowedClasses = align-left, align-center, align-right
buttons.blockstyle.tags.div.allowedClasses := addToList(csc-frame-frame1, csc-frame-frame2)
buttons.blockstyle.tags.table.allowedClasses = csc-frame-frame1, csc-frame-frame2
buttons.blockstyle.tags.td.allowedClasses = align-left, align-center, align-right
buttons.textstyle.tags.span.allowedClasses = important, name-of-person, detail
contentCSS = typo3conf/ext/fluxtemplate/Resources/Public/CSS/rte.css
buttons.formatblock.prefixLabelWithTag = 1
buttons.link.relAttribute.enabled = 1
buttons.link.queryParametersSelector.enabled = 1
buttons.link.properties.class.allowedClasses = external-link, external-link-new-window, internal-link, internal-link-new-window, download, mail
buttons.link.page.properties.class.default = internal-link
buttons.link.url.properties.class.default = external-link-new-window
buttons.link.file.properties.class.default = download
buttons.link.mail.properties.class.default = mail
buttons.image.properties.class.allowedClasses = img-responsive
// Disable contextual menu
contextMenu.disabled = 1
// Display status bar
showStatusBar = 1
//More toolbar options
keepButtonGroupTogether = 1
// Use CSS formatting when possible
useCSS = 1
// Make rtehtmlarea resizable
rteResize = 1
proc {
allowedClasses = external-link, external-link-new-window, internal-link, internal-link-new-window, download, mail
allowedClasses := addToList(detail,align-left, align-center, align-right, align-justify, csc-frame-frame1, csc-frame-frame2, component-items, action-items, component-items-ordered, action-items-ordered, important, name-of-person, indent, img-responsive)
allowedClasses < RTE.default.classesCharacter
# auskommentieren, damit klassen eingelesen werden können
#allowedClasses := addToList( dimmed,highlight,box,info,success,warning,error,float-left,float-right,center,align-left,align-center,align-right,align-justify,style1 )
## TAGS ALLOWED OUTSIDE P & DIV
allowTagsOutside := addToList( pre, img )
allowTags := addToList( pre )
// Tags allowed in Typolists
allowTagsInTypolists = br,font,b,i,u,a,img,span
// Keep unknown tags
dontRemoveUnknownTags_db = 1
// Allow tables
preserveTables = 1
entryHTMLparser_db = 1
entryHTMLparser_db {
// Tags allowed
allowTags < RTE.default.proc.allowTags
// Tags denied
denyTags >
// HTML special characters
htmlSpecialChars = 0
// Allow IMG tags
tags.img >
// Additionnal attributes for P & DIV
tags.div.allowedAttribs = class,style,align
tags.p.allowedAttribs = class,style,align
// Tags to remove
removeTags = center, font, o:p, sdfield, strike, u
// Keep non matched tags
keepNonMatchedTags = protect
}
// HTML parser
HTMLparser_db {
// Strip attributes
noAttrib = br
// XHTML compliance
xhtml_cleaning = 1
}
// Exit HTML parser
exitHTMLparser_db = 1
exitHTMLparser_db {
// Remap bold and italic
tags.b.remap = strong
tags.i.remap = em
// Keep non matched tags
keepNonMatchedTags = 1
// HTML special character
htmlSpecialChars = 0
}
}
}
RTE.default.FE < RTE.default
RTE.default.FE.showButtons < RTE.default.showButtons
RTE.default.FE.proc.allowTagsOutside < RTE.default.proc.allowTagsOutside
RTE.default.FE.proc.entryHTMLparser_db.tags.img >
// PageTSConfig
TCEFORM.tt_content.header_layout.altLabels {
0 = H1 (Default)
1 = H1
2 = H2
3 = H3
4 = H4
5 = H5
}
I also have same problem in my another project.
First set default_charset to utf8 in your php.ini file.
or you can manuaaly set it with below PHP code:
ini_set('default_charset', 'utf8');
Currently I am working on a new traveling website, but am having problems with 1 thing:
I have a list with all the country's, regions and city's i want to publish. How do I quickly create a page for all of them like this:
Every page should be a subpage like: country/region/city
Every page should have a certain page template
Please let me know, thanks in advance for your time and information!
You can do something like this.
<?php
// $country_list = get_country_list(); // returns list, of the format eg. array('India' => 'Content for the country India', 'Australia' => 'Content for the country Australia')
// $region_list = get_region_list($country); // Get the list of regions for given country, Assuming similar format as country.
// $city_list = get_city_list($region); // Get the list of cities for given region, Assuming similar format as country
/* Code starts here...*/
$country_list = get_country_list();
foreach($country_list as $country_title => $country_content) {
$country_template = 'template_country.php';
$country_page_id = add_new_page($country_title, $country_content, $country_template);
// validate if id is not 0 and break loop or take needed action.
$region_list = get_region_list($country_title);
foreach($region_list as $region_title => $region_content) {
$region_template = 'template_region.php';
$region_page_id = add_new_page($region_title, $region_content, $region_template, $country_page_id);
// validate if id is not 0 and break loop or take needed action.
$city_list = get_city_list($region_title);
foreach($city_list as $city_title => $city_content) {
$city_template = 'template_city.php';
add_new_page($city_title, $city_content, $city_template, $region_page_id);
}
}
}
function add_new_page($title, $content, $template_file, $post_parent = 0) {
$post = array();
$post['post_title'] = $title;
$post['post_content'] = $content;
$post['post_parent'] = $post_parent;
$post['post_status'] = 'publish'; // Can be 'draft' / 'private' / 'pending' / 'future'
$post['post_author'] = 1; // This should be the id of the author.
$post['post_type'] = 'page';
$post_id = wp_insert_post($post);
// check if wp_insert_post is successful
if(0 != $post_id) {
// Set the page template
update_post_meta($post_id, '_wp_page_template', $template_file); // Change the default template to custom template
}
return $post_id;
}
Warning: Make sure that the is executed only once or add any validation to avoid duplicate pages.