orderBy in recursive select query (typo3 / typoscript) - typo3

I have a problem ordering the results from a recursive select-query.
It's just about ordering 2 levels of pages. I want the result to look like this:
Parent 1
Child 1-1
Child 1-2
Parent 2
Child 2-1
Child 2-2
Child 2-3
In my results I want one parent page followed by its children, then the next parent's page followed by its children and so on.
When using orderBy = sorting, I seem to get the results in a kind of "random" order, because it's sorting all the entries by the "sorting" field. It is ignoring if the result is a parent or a child-page of the result.
If I don't use orderBy at all, I get the parent's pages first, then the child's pages (maybe this is just a random result).
How can I sort my results correctly?
(I've been thinking about a workaround, using HMENU or TMENU to display my results in the correct order)
Here's my typoscript:
table=pages
select{
pidInList={leveluid:1}
pidInList.insertData=1
recursive=1
orderBy=sorting
max=200
}

Another option would be to nest the SELECT queries.
If you have the result cached, it's the same anyways ;)
tmp.data = CONTENT
tmp.data {
table = pages
select {
pidInList.data = leveluid:1
orderBy = sorting
max = 200
}
renderObj = CONTENT
renderObj {
table = pages
select {
pidInList.field = uid
orderBy = sorting
}
}
}

Related

Is there a CDS view annotation (ABAP) to remove/select a field?

I created an ABAP CDS view from a dataset. This dataset contains data with a field "OrderID" (from order 1 to order 10000). Based on this field, OrderID, I would like to create 2 query views : one containing only data from order 1 to 20 and another one with order 50 to 70.
Therefore, I was wondering if there is an annotation to select the value I want to show/remove. I don't want to filter for performance reason.
Use a where clause, as described in the ABAP keyword documentation:
define view first_query_view as
select from your_base_view
{ ... }
where OrderID between 1 and 20;
define view second_query_view as
select from your_base_view
{ ... }
where OrderID between 50 and 70;
Annotations explain how views and the elements in them are to be used. They don't control how the data is retrieved, joined, or filtered.

TYPO3 typoscript WHERE anotation, what is the difference?

In selecting specific content I collect only the elements from the column that has colPos = 1, I have two annotations that work for the where clause and I'd like to understand the difference;
10 = CONTENT
10 {
table = tt_content
select {
pidInList = this
orderBy = sorting
where = {#colPos}=1
where = colPos = 1
}
renderObj = COA
renderObj {
10 = TEXT
10.stdWrap.field = header
}
}
The first version ensures proper quoting for SQL field names, the second version does not. This ensures compatibility with various DBMS. You should always use the first version if possible.
The annotation with the curly brackets has been introduced in TYPO3 V8.

Look up a record with Fluid DatabaseQueryProcessor – without PID

In TYPO3 7.6, I would like to look up records from another (=any) page in a Fluidtemplate.
Based on https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Fluidtemplate/Index.html, I tried DatabaseQueryProcessor:
renderObj = FLUIDTEMPLATE
renderObj {
file = {$fluidPartialsPath}/Debug.html
dataProcessing {
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20{
# regular if syntax
if.isTrue.field = records
table = tt_content
# quick&dirty to see the SQL table
# where = stubrdebug
# will pass these in programmatically later
colPos = 1
uidInList = 5
# this doesn't work
pidInList = *
as = myrecords
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
}
}
}
}
}
The issue is that select always asks for a pid or add the one of the current page. So it behaves like a CONTENT Object.
How can I leave out the PID in the query?
All answers I could google point to simply using RECORDS – but I don't see how I could do that in dataProcessing.
Is there a way?
PS on a larger scale: I would like to use fluid_styled_content's "Insert Records" Content Element to insert OTHER (=not from fsc), custom record types into the current page. I'm trying to build an own way to do that. Please tell me if that doesn't make sense and / or if there's an easier way than building everything from scratch.
As far as I can tell, dataProcessing only works on the current $data variable which needs to be filled in before, e.g. by a CONTENT object.
The CONTENT object uses the select function to get is data, therefore you have to use its pidInList property to configure the range of pages taken into account. Records without a page should live in the root (pid=0) and can be selected by the root keyword.
If you want to create a Insert Records functionality, then you should already have a list of uidfrom your records. Then you can simply use the RECORDS object to render the specific record, no matter on what page it is on.

tt_news single view with static news_id

I am using Typo3 Version 6.2 with the plugin tt_news.
All I want to do is:
Have a simple page on my website
On that page I want to have a tt_news single view
the news_id of this view should be static (set by me) and NOT by GET variables
Use Case:
We have a company with many departments. For every department we have a couple of subpages on our website. Now I want to add specific news to each of those department websites. Like: On the team management page I want to show the news with ID = XY.
Is there any way to get this working?
Insert the following lines to the setup field of an ext-template at the page where you want to display the selected news item in SINGLE view if no SINGLE view for another record was requested:
# hide the "no news id" message
plugin.tt_news._LOCAL_LANG.default.noNewsIdMsg =
# set the tt_news singlePid to the current page
plugin.tt_news.singlePid = 977
# fill the content of the main-column to a tmp.object
tmp.pagecontent < page.10.subparts.contentarea
# clear the content of the main column
page.10.subparts.contentarea >
# build a new object for this column as content-object-array
page.10.subparts.contentarea = COA
page.10.subparts.contentarea {
10 = CONTENT
10.table = tt_news
10.select {
# insert the pids of all pages from where you want to fetch news.
# the recursive-field has no influence on this selection
pidInList = 25 # your pid
# orderBy = datetime desc
max = 1
# get element with news id 10 #zarathustra
where = tt_news.uid=10
}
# insert the object “10.” only if there is no SINGLE news selected
10.stdWrap.if.isFalse.data = GPvar:tx_ttnews|tt_news
# re-insert the normal pagecontent to the page
20 < tmp.pagecontent
}
More information here
http://docs.typo3.org/typo3cms/extensions/tt_news/3.5.1/ExtNews/Configuration/TyposcriptExamples/Index.html#default-news-id

Typo3 6.2.x sys_category renderMode

We are using a Typo3 6.2.9 with the tx_news extension (3.1.0) with a bunch of sys_category objects.
In FrontEnd every article has a link to its "primary" category page - which means we make a link to the category news page using newsItem.categories.0.uid in the template.
I know that sorting is supported because I manually exchanged the sorting values of two sys_category_record_mm entries of an article.
update sys_category_record_mm set sorting_foreign=<sortingvalue1> where uid_local = <sys_category_uid2> and uid_foreign = <tx_news_domain_model_news_uid>;
update sys_category_record_mm set sorting_foreign=<sortingvalue2> where uid_local = <sys_category_uid1> and uid_foreign = <tx_news_domain_model_news_uid>;
I also know that the following line in the pageconfig of my root-page disables the category field:
TCEFORM.tx_news_domain_model_news.categories.disabled = 1
Therefore I know that
TCEFORM.tx_news_domain_model_news.categories
adresses the correct field.
Now I would like to change the renderMode of the categories field for news items. The default renderMode "tree" does not support sorting of the categories.
Thats why I'd like to change it to the one the was used in older Typo3 versions, the one that is still used with tags.
I tried:
TCEFORM.tx_news_domain_model_news {
categories{
select >
group >
check >
group {
size = 5
autoSizeMax = 10
max_size = 10
show_thumbs = 0
maxitems = 100
minitems = 0
disable_controls = 0
}
}
and
TCEFORM.tx_news_domain_model_news {
categories{
config.select.renderMode = singlebox
}
and
TCEFORM.tx_news_domain_model_news {
categories{
config.renderMode = singlebox
}
and other variations there upon.
Has anyone an idea what I am doing wrong?
As far as I know, you cannot sort categories within the selection tree.
But you can sort them.
Just got to the page/folder where you created the categories - be sure to be on list module - and there you have the sorting buttons.
 
list module - data storage - see the order
 
category selection tree - compare with the order above