显示 TYPO3 内容仅在工作时间内,通过每个工作日定期发布和取消发布内容。

huangapple go评论50阅读模式
英文:

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

问题

我想要在每周一到周五的上午9点到下午5点之间显示一个TYPO3内容元素。使用默认选项,我只能添加一个发布日期和时间以及一个过期日期和时间。

在TYPO3 v10中,我应该如何管理这个(在服务器端,而不使用JavaScript)?

我找到了一个扩展(Content Scheduler),可以管理重复发布和取消发布日期,但无法定义类似于"每个工作日"的情况。

我考虑使用TYPO3调度程序(或本机cron作业)调用CLI命令,但TYPO3没有提供一个命令来发布和取消发布内容元素。

有什么想法吗?也许可以使用老式的TypoScript?

英文:

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?

答案1

得分: 1

所有记录的可见性时间不是周期性的,而是在固定日期(和时间)上开始和/或结束可见性。

我知道的唯一选项,可以忽略完整时间戳的一部分是TypoScript中的条件
TYPO3 10的条件在这个手册中有描述。

这将导致类似于以下的TypoScript:

[date("G") > 8 && date("G") < 17]
page.10.variables.content < styles.content.get

[else]
page.10.variables.content = TEXT
page.10.variables.content.value = 对不起我们已经关闭<br />请在早上9点回来
[global]

当然,这不会考虑周末,您需要对其进行增强。
注意您不能将条件嵌套在彼此之中!

[date('N') > 5]
// 仅适用于星期六和星期日:
page.10.variables.content = TEXT
page.10.variables.content.value = 对不起我们已经关闭<br />请在星期一早上9点回来

[date('N') == 5 && date('G') > 16]
// 星期五晚上
page.10.variables.content = TEXT
page.10.variables.content.value = 对不起我们已经关闭<br />请在星期一早上9点回来

[date("G") > 8 && date("G") < 17]
page.10.variables.content < styles.content.get

[else]
page.10.variables.content = TEXT
page.10.variables.content.value = 对不起我们已经关闭<br />请在早上9点回来
[global]

此外,您还可以在FLUID中计算这些条件。可以使用您提供的适当变量(用于星期几和小时),或者使用匹配的视图助手:

如果您想要使用PHP在一周的不同时间提供不同的内容,可以使用以下方式:

  • 为自己的条件编写自定义userFunction
  • 或者为自己的ViewHelper
  • 或者使用内部处理的特殊内容的控制器
英文:

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

huangapple
  • 本文由 发表于 2023年2月10日 02:35:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75403014.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定