Conditional if a post in tt_news belongs to certain category - typo3

I made a custom marker for tt_news which shows the first image from the media field, OR the third if it belongs to certain category (lets say category with ID = 2). I dont know how to make that conditional. This is what I have so far:
10 = IMAGE
10.file{
width = 550
height = 350
import = uploads/pics/
import{
field = image
listNum = 0
#If also belongs to the category "Startseite", the listNum should be 2
listNum.stdWrap.override = TEXT
listNum.stdWrap.override{
value = 0
if{
#??????
}
}
}
}

You need to write custom condition as described in doc in userFunc section (bottom)
http://typo3.org/documentation/document-library/core-documentation/doc_core_tsref/4.3.2/view/1/4/
News and categories are connected with MM relation so you just to check if MM table contains this pair...
typo3conf/localconf.php:
function user_newsInCategory($catUid) {
$ttNewsGet = (t3lib_div::_GP('tx_ttnews'));
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'uid_foreign',
'tt_news_cat_mm',
'uid_foreign = ' . $catUid . ' AND uid_local=' . intval($ttNewsGet['tt_news'])
);
return ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) ? true : false;
}
somwhere in TS after your 10 = IMAGE { ... } block:
[userFunc = user_newsInCategory(2)]
10.file.import.listNum = 2
[end]
edit:
As you can see in the sample it works only if news is displayed (ie. if param &tx_ttnews[tt_news] exists in URL)
To check similar check per each list item you need to use custom marker via hook (as described in tt_news manual) by using extraItemMarkerProcessor - then you can use similar condition per each $row to display different images.

Related

powermail should update a `pages`-field

I want to use powermail (7.4.0) to give special page visitors the option to modify a field in the current pages record.
my setting so far:
plugin.tx_powermail.settings.setup {
dbEntry {
1 {
_enable = TEXT
_enable.value = 1
_table = TEXT
_table.value = pages
uid = TEXT
uid.data = TSFE:id
description = TEXT
description.field = abnahmestatus
}
}
prefill {
abnahmestatus = TEXT
abnahmestatus.data = TSFE:description
}
}
How can I get powermail to update the record (instead of inserting)?
How can I prefill the input field with the current value from the pages field?
Answer 1: update instead of insert:
I missed the line
_ifUnique.uid = update
from the manual example.
Answer 2:
I inserted {abnahemstatus} which was not helpfull as it overwrote the typoscript prefill. so:
no value in prefill_value of the field definition
the correct definition is abnahmestatus.data = page:description (TSFE is obsolete)

How to communicate two plugins of News for Typoscript

I have to show in my single page: the single and the list of News with the same categories of single new. I have two plugins in my backend page and have tried to assign the categories of single to the list for typoscript, but i could not do it.
This is the code, i used page.x for debug and catch values:
page.100 = TEXT
page.100.data = GP:tx_ttnews|tt_news
page.100.wrap = The single tt_news id is: |
page.100.data = GP:tx_ttnews|cat
page.100.wrap = The category of single is: |
page.110 = TEXT
page.110
{
value = { register:newsCategoryUid }
insertData = 1
wrap = - Categories: |
}
plugin.tt_news
{
categorySelection = { register:newsCategoryUid }
#show only selected categories
categoryMode = 1
}
It's not fully visible what you're trying. I think the best way should to put the cat value inside a temp object. Do you have the plugins inserted by TypoScript or as Content Element? You are using tt_news not news by georg ringer right?
temp.tx_news_catId = TEXT
temp.tx_news_catId.data = GP:tx_ttnews|cat
temp.tx_news_catId.intval = 1
page.110 < temp.tx_news_catId
page.110.wrap = Category: |
plugin.tt_news
{
categorySelection < temp.tx_news_catId
# you need to use data not categorySelection = {...} <- that should
# only work on constants
# but only works if categorySelection capabilities
#categorySelection.data = register:newsCategoryUid
#show only selected categories
categoryMode = 1
}
(Untested TypoScript)
hope this helps you a little bit
PS: Have you checked whether categorySelection has stdWrap capabilities?
I don't really get what you want to do, maybe this helps a bit:
If you want to show in the detail action articles with the same category as the current one, you can use a snippet like this one:
Add this to the Detail.html which will pass the first category uid to the TypoScript object lib.tx_news.relatedByFirstCategory.
<f:if condition="{newsItem.firstCategory}">
<f:cObject typoscriptObjectPath="lib.tx_news.relatedByFirstCategory">{newsItem.firstCategory.uid}</f:cObject>
</f:if>
and the TS:
lib.tx_news.relatedByFirstCategory = USER
lib.tx_news.relatedByFirstCategory {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
relatedView = 1
detailPid = 31
useStdWrap := addToList(categories)
categories.current = 1
categoryConjunction = or
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 78
}
}
I have taken this from the manual.

Solr Indexing - Manipulating the search result

I am working with the TYPO3 Solr extension and I have some doubts regarding the solr result set manipulation.
I have added a special configuration for indexing some particular pages in my page tree. ie Pages that starts with the label "Expertise%" .I have managed to added this successfully . And the indexing is working successfully with our any trouble. But what I would like to achieve is that , I want to added parent page title to the search result.i.e
This is the page tree
|---- 1.00.100 (parent page)
|--Subpage 1
|--Subpage 2
|--Expertise
|--Test page`
And in the solr search result should be
1.00.100 - Expertise
Is this possible in TYPO3 Solr. Is there any hook or signalslot available to implement this?
Tried this ,But doesn't seems to work for me ?
plugin.tx_solr.index.queue.expertise_offered = 1
plugin.tx_solr.index.queue.expertise_offered {
table = pages
additionalWhereClause = doktype = 1 AND no_search = 0 AND title LIKE '%Expertise offered%'
fields {
title = title
content = CONTENT
parentPageTitle_stringS = CONTENT
parentPageTitle_stringS {
table = pages
select {
selectFields = title
where = uid = ###pid###
}
markers {
pid.data = field:pid
}
}
content {
table = tt_content
select {
selectFields = header, bodytext
}
renderObj = COA
renderObj {
10 = TEXT
10.field = header
# This removes HTML tags
11 = SOLR_CONTENT
11.field = bodytext
}
}
url = TEXT
url.typolink.parameter = TEXT
url.typolink.parameter.field = uid
}
}
You probably don't need any hook or signal-slot. You can do it as follows:
Add the title of the parent page to your indexing configuration. There is no field for it, but you can dynamically add fields to SOLR documents. This is done by sending the data in a field which has a certain suffix, which determines the field type.
For example: Setting the field parentPageTitle_stringS to the parent pages title in the indexing configuration creates a new stored, single-valued field of type string in the indexed document.
Filling this field could look like this:
plugin.tx_solr {
index {
queue {
<yourindexconfigname> = 1
<yourindexconfigname> {
table = pages
fields {
parentPageTitle_stringS = CONTENT
parentPageTitle_stringS {
# Build a query here to retrieve
# the parent page title.
}
}
}
}
}
}
In your template for search results, you can use the marker ###RESULT_DOCUMENT.parentPageTitle_stringS### to retrieve the field.
The available field types can be found in EXT:solr/Resources/Solr/typo3cores/conf/general_schema_fields.conf from line 157 onwards (refering to version 3.0.0 here).
You should of course use a type other than string if you want to have the result indexed nicely.

Creating dynamic fields in Powermail 2.x

I have a doubt with powermail 2.x extension .
My actual requirement is , I have a form (custom extension) through which I can search some places using zip code. So once user submits the value (eg zip code) , the webiste will be redirected to page where I list all available places under that zip code as link. When a user clicks on that link , Website will be redirected to another page where I hvae configured powermail 2.x extension . What I want to implement is , based on link clicked (I will be passing place_id through the link and each place have some membership types).I want to show a set of membership types in radio buttons(Fetched from another table using the arguments from url). and this items should be there in preview and mail as well.
The same thing we can implement using $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldHook'] in powermail 1.6 ?
How we can implement the same in powermail 2.x??
Any help would be appropriated ?
Finally I have managed to fix it by myself.
All you have to do is,
Add a new check box field in the powermial form , In the extended tab , you can assign a typoscript variable something like lib.products .
lib.products = CONTENT
lib.products {
table = pages
select {
pidInList = xxx
}
renderObj = COA
renderObj {
10 = COA
10 {
10 = TEXT
10.dataWrap = {field:title}[\n]
}
}
}
Above code will generate dynamic radio buttons in the frontend.Again if you wish to like create custom field type in powermail field.
tx_powermail.flexForm.type.addFieldOptions.new = Name of the field
tx_powermail.flexForm.type.addFieldOptions.new.dataType = 1 (If it is an array)
After that add the below typoscript code
plugin.tx_powermail.view {
partialRootPath >
partialRootPaths {
10 = EXT:powermail/Resources/Private/Partials/
20 = EXT:extension/Resources/Private/Partials/
}
}
and create a template fileEXT:extension/Resources/Private/Partials/New.html.In that file , you can include field(checkboxes radio buttons or selectboxes).
After that
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\SignalSlot\Dispatcher');
$signalSlotDispatcher->connect(
'In2code\Powermail\Controller\FormController',
'formActionBeforeRenderView',
'HEV\Extension\Controller\FormController',
'customfucntion',
FALSE
);
we have to implement the signal slot available in powermail 2.X
and in the the
/**
* #param \In2code\Powermail\Domain\Model\Form $form
* #param \In2code\Powermail\Controller\FormController $pObj
*/
public function manipulateMailObjectOnCreate($form, $pObj) {
$sectionNr = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP("SID");
if ( !isset( $sectionNr ))
return ;
foreach ( $form as $forms ){
foreach( $forms->getPages() as $key => $pages){
foreach ( $pages->getFields() as $fields ){
switch ( $fields->getType() ){
case "new":
$fields->setMandatory(TRUE);
$fields->setCreateFromTyposcript('lib.products');
break;
}
}
}
}
}

How can I create a link to a specific, known page using TypoScript?

I am working on some Typo3 6.2 templates. I want to insert a link into the template using Typoscript.
I have a constant {$HOME_SHORTCUT}, which has the title "Startseite" & the path /start. I want the link to look like this:
Startseite
I am using this to insert the link before a set of breadcrumbs. The link path is correct but the value/text of the link is the pageID of {$HOME_SHORTCUT}, not the header text, which is what I want:
stdWrap.prepend = TEXT
stdWrap.prepend {
value = {$HOME_SHORTCUT} ###HOW DO I USE THE TITLE OF THE PAGE AS THE VALUE?####
stdWrap.typolink {
field = header
parameter = {$HOME_SHORTCUT}
}
}
This outputs:
146
Which is incorrect. That's the page ID, not the header. How do I get the header of {$HOME_SHORTCUT}?
When you leave out the "value" the page title is set automatically:
stdWrap.prepend = TEXT
stdWrap.prepend.typolink.parameter = {$HOME_SHORTCUT}
Following along with this answer, I constructed this, which gives the desired mark-up:
stdWrap.prepend = TEXT
stdWrap.prepend {
value {
table = pages
select {
where = uid = {$HOME_SHORTCUT}
}
renderObj {
10 = TEXT
10 {
field = title
wrap = |
}
}
}
stdWrap.typolink {
field = header
parameter = {$HOME_SHORTCUT}
}
}
Which seems like a really, really long-winded way of saying "Wrap this page title with a link to this page"- I am definitely interested in hearing of better methods.