Show TYPO3 content only during working hours by recurrently publish and unpublish content every working day - typo3

I want to display a TYPO3 content element every Monday till Friday between 9am and 5pm. With the default options I am only able to add a single publish and a single expire date and time.
How could I mange this in TYPO3 v10 (on the server side without using JavaScript)?
I found an extension (Content Scheduler), that can manage recurring publishing and unpublishing dates but it's not possible to define s.th. like 'every working day'.
I was thinking about using the TYPO3 scheduler (or native cron job) calling a CLI command but TYPO3 does not offer a command to publish and unpublish content elements.
Any ideas? Maybe using the good old TypoScript?

All visibility timings of records is not periodical but on fixed dates (and times) for starting and/or ending of visibility.
The only option I know where you can ignore parts of the full timestamp are conditions in TypoScript.
The condition for TYPO3 10 is described in this manual
this will result in a typoscript like this:
[date("G") > 8 && date("G") < 17]
page.10.variables.content < styles.content.get
[else]
page.10.variables.content = TEXT
page.10.variables.content.value = Sorry. we are closed.<br />Please come back at 9:00.
[global]
Of course this will not consider the weekend and you need to enhance it.
Note that you can't stack conditions into each other!
[date('N') > 5]
// just saturday and sunday:
page.10.variables.content = TEXT
page.10.variables.content.value = Sorry. we are closed.<br />Please come back on Monday at 9:00
[date('N') == 5 && date('G') > 16]
// friday in the evening
page.10.variables.content = TEXT
page.10.variables.content.value = Sorry. we are closed.<br />Please come back on Monday at 9:00
[date("G") > 8 && date("G") < 17]
page.10.variables.content < styles.content.get
[else]
page.10.variables.content = TEXT
page.10.variables.content.value = Sorry. we are closed.<br />Please come back at 9:00
[global]
You also can compute these conditions in FLUID. Either with apropiate variables you provide (for dayOfWeek and hour)
or with a matching viewhelper:
If you want to use PHP to provide different content at different times in the week you can do it with:
your own userFunction for your own condition
or your own ViewHelper
or an controller for special content which handles it internally

Related

Typo3 tt_news disabled date

I am facing problem with tt_news in typo3 version 6.2.11.
I can not set date above 2020 year. I can set till 31.12.2020 and after that all dates are disabled.
I have taken 2 screenshot of it. Any hint or solution would help me.
Thanks
enter image description here
tt_news has a hardcoded maximum for the end date, which in the version you're using is 31-12-2020. The best advice is to upgrade. TYPO3 6.2 isn't supported anymore.
However, if you need a quick fix, you'll need to change it in the TCA file of tt_news. You can find that in typo3conf/ext/tt_news/tca.php or typo3conf/ext/tt_news/Configuration/TCA/tt_news.php depending on which version of the extension you're using.
This file contains an array with the configuration of the fields for this table. For the field endtime it should contain something like this:
'range' => [
'upper' => mktime(0, 0, 0, 31, 12, 2020)
]
You'll need to change that date.
The range-array occurs twice in tca.php. The first occurrence should be updated
$TCA['tt_news']['columns']['endtime']['config']['range']['upper']
At the next one you can do as well
$TCA['tt_news_cat']['columns']['endtime']['config']['range']['upper']
My fault was to change the latter one without effect.

Set datepicker for one year from today in Cypress test

I am creating an acceptance test in Cypress that will run regularly, and I need that it enters the date from the datepicker (React, if it is important) as 1 year 1 month and 1 day from the day of creating the object (article). E.g. Today is April 22, 2020, and I want to get May 23, 2021 in the article created today, and tomorrow it would give the value of May 24, 2021 etc. Could anyone share any ideas of setting this up? I honestly googled and I have no ideas myself because I'm quite new to Cypress and feel more or less confident only in pretty straightforward things. :)
I'd guess that most date pickers will have an input element where the date can be typed.
Presuming the app uses a library date picker (so you don't need to test the picking of the date via button clicks), you can target that element and use the Cypress .type() command to enter the future date.
For example, the Material UI date picker docs has this input element
<input aria-invalid="false"
id="date-picker-inline"
type="text"
class="MuiInputBase-input MuiInput-input MuiInputBase-inputAdornedEnd"
value="08/18/2014">
so the steps would be something like
cy.visit('https://material-ui.com/components/pickers');
const targetDate = Cypress.moment()
.add(1, 'year')
.add(1, 'month')
.add(1, 'day')
.format('MM/DD/YYYY') // adjust format to suit the apps requirements
cy.get('input[id="date-picker-inline"]')
.clear()
.type(`${targetDate}{enter}`) // presume you need the enter key to trigger an event
Ref: Cypress.moment
This method was deprecated. You can use this method;
//click the date picker
cy.get('#datepicker').click();
//choose previous month
cy.contains('Prev').click();
//choose next month
cy.contains('Next').click();
//choose date 24
cy.contains('24').click();

TYPO3 tx_news entries within a date range

I am currently migrating tt_news to news. The old news system also has news-entries shown as events. Is it somehow possible to hide entries that are past, without having to archive those? Or else to show only entries within the next x days?
This was possible with tt_news typoscript:
extensions.ttnews_selectconf {
andWhere (
tt_news.datetime < (UNIX_TIMESTAMP() +604800)
AND tt_news.datetime > (UNIX_TIMESTAMP()-86400)
)
}
I could not find anything in the news docs.
The news extension has a TypoScript option to set a minimum date/time: https://docs.typo3.org/typo3cms/extensions/news/stable/AdministratorManual/Configuration/TypoScript/Index.html#timerestriction
So plugin.tx_news.settings.timeRestriction = now will show news items starting now. plugin.tx_news.settings.timeRestriction = today will show news items starting at the start of today.
For a maximum date you can use timeRestrictionHigh
Also, if you're using news for events, you might want to check out the eventnews extension. This extends the news extension to add fields and views that are useful for events. https://extensions.typo3.org/extension/eventnews

Liferay date-input displays wrong date

I'm using Liferay 7.1 I have the following liferau-ui:input-date object and I want to pre-select a date:
<%
final LocalDate today = LocalDate.now(ZoneId.systemDefault());
%>
<liferay-ui:input-date
dayValue="<%= today.getDayOfMonth()%>"
monthValue="<%=today.getMonth().getValue()%>"
yearValue="<%= today.getYear()%>"
</liferay-ui:input-date>
When I output today's values directly on the JSP I get the correct date for today: 3 12 2018.
When the element is rendered, it has selected the wrong date: 01/03/2019. There is nothing further documented in the taglibdocs that I think could help.
How can I fix this?
The problem is the month value. In Java it's 1-12 with liferay datepicker it's 0-11.
In order to display the correct month i subtracted 1 from month value. It's not an elegant solution but i couldn't find any better way.
<liferay-ui:input-date
dayValue="<%= today.getDayOfMonth()%>"
monthValue="<%=today.getMonth().getValue() - 1 %>"
yearValue="<%= today.getYear()%>"
</liferay-ui:input-date>
This will render 12/03/2018

Ng Bootstrap DatePicker , show next month instead of current

I am using ng bootstrap datepicker to set up a calendar.
But my requirement is, instead of the calendar to display the current Month as it does. I need it to display the next Month..i.e January.
I read through the documentation and I can't seem to find a way to customize this.
Is there a way to do this ?
To change the default of the month being displayed ?
It's a basic datepicker :
<ngb-datepicker #dp [(ngModel)]="model" (navigate)="date = $event.next"></ngb-datepicker>