tt_news single view with static news_id - typo3

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

Related

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.

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

orderBy in recursive select query (typo3 / typoscript)

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
}
}
}

Drupal onChange auto populate another CCK select list

I have built a multistep form using CCK, however I have a couple of issues outstanding but, not sure if CCK can help.
In one step of the form I have 2 select boxes, the first is auto populated from the vocabulary table with the following code and all woks well.
$category_options = array();
$cat_res = db_query('select vid, name from vocabulary WHERE vid > 1 ORDER BY name ASC');
while ($cat_options = db_fetch_object($cat_res)) {
$category_options[$cat_options->vid] = $cat_options->name;
}
return $category_options;
What I would like to do is, when a user selects one item from the vocablulary list it auto populates another select box with terms from the term_data table. I have 2 issues;
1) I have added the following code to the second select list, just to make sure it works (IT DOESN'T). There a multiple terms associated with each vocabulary, but the second sql statemant only returns one result when it should return several, (SO SOMETHING WRONG HERE). For example in the term_date table there are 6 terms with the vid of 3, but I only get one added to select list.
$term_options = array();
$term_res = db_query('select vid, name from term_data WHERE vid = 3 ORDER BY name ASC'); while ($options = db_fetch_object($term_res)) {
$term_options[$options->vid] = $options->name;
}
return $term_options;
2) Can I add an onChange to the first select list to call a function to auto populate second list using CCK, or do I have to lean towards doing my entire form using the FORM API.
Any help or thoughts would be very much appreciated.
It seems to be a mistake in the query that gets terms. I tried to correct:
$term_res = db_query('select tid, name from term_data WHERE vid = 3 ORDER BY name ASC');
while ($options = db_fetch_object($term_res)) {
$term_options[$options->tid] = $options->name;
}
In your code you selected vid that is actually equal for all terms. Then you added terms names to $term_options array under the same key => so you got only 1 element.
Considering the second question: I would send the whole data structure (all vocabularies and their terms) as json to the client (insert a js script to the page from your drupal code) and implement the desired functionality with jquery.