如何在 TYPO3 7.6.14 中使用 Calendar Base 扩展在同一页面中混合月视图和列表视图

How mix Month view and List view in same page with Calendar Base extension in TYPO3 7.6.14

我看过 Calendar Base 的代码,但我一直不明白作为工作标记的方式及其在代码中的功能。

我想知道是否可以创建一个迷你日历,在我单击某一天的那一刻,事件会显示在列表下方。

请指导我如何解决它,不要给我代码。

EXT:cal 有很多可能的配置。 我只会在 TYPO3 CMS 7.6 中给出 EXT:cal 版本 1.10.3 的最低要求配置,因为我用于我的一个项目(不是滑动项目,正如我在第一条评论中提到的那样)。

您已安装 EXT:cal 并包含静态错字('Standard CSS-based template',也许 'Standard CSS styles' ).

在 TYPO3 的日历页面上,您创建了两个插件类型的内容元素,您在其中选择 'TYPO3 calendar' 作为插件。 month-mini-view 的第一个内容元素,list-view 的第二个内容元素,具有以下配置:

  1. Contentelement 插件 month-mini-view:

选项卡'General settings' 字段 'Allowed views' select 'Month' 仅。

选项卡'Month view' 字段 'Display as a mini calendar' 激活复选框。

  1. Contentelement 插件 list-view:

选项卡'General settings' 字段 'Allowed views' select'List''Single Event'顺序。

插件配置中的所有其他字段为空或具有默认值。我宁愿不使用字段记录存储页面,而是使用拼写错误'plugin.tx_cal_controller.pidList'

在前端您应该已经看到 month-mini 和列表视图。

将以下错别字配置(设置)添加到您的页面树中,我发现这在组合使用 mont-mini 和列表视图时很有用:

// General
plugin.tx_cal_controller.pidList = [!!!-FILL_HERE_YOUR_CAL_STORAGE-PIDS-PLEASE-!!!]

// List view
plugin.tx_cal_controller.view.list.starttime = today
// Use getdate and custom start&end date to use link from minical inside listview
[globalVar = GP:tx_cal_controller|year >0]
  plugin.tx_cal_controller.view.list.useGetdate = 1
[else]
  plugin.tx_cal_controller.view.list.useGetdate = 0
[global]
// Adapt list view for urls from monthMini view
// year-view: if (yaer=true && month=false && week=false && day=false)
[globalVar = GP:tx_cal_controller|year >0] && [globalVar = GP:tx_cal_controller|month <1] && [globalVar = GP:tx_cal_controller|week <1] && [globalVar = GP:tx_cal_controller|day <1]
  plugin.tx_cal_controller.view.list.useCustomStarttime = 1
  plugin.tx_cal_controller.view.list.useCustomEndtime = 1
  plugin.tx_cal_controller.view.list.customStarttimeRelativeToGetdate = 1
  plugin.tx_cal_controller.view.list.customEndtimeRelativeToGetdate = 1
  plugin.tx_cal_controller.view.list.starttime = yearstart
  plugin.tx_cal_controller.view.list.endtime = yearend
[global]
// month-view: if (month=true && day=false)
[globalVar = GP:tx_cal_controller|month >0] && [globalVar = GP:tx_cal_controller|day <1]
  plugin.tx_cal_controller.view.list.useCustomStarttime = 1
  plugin.tx_cal_controller.view.list.useCustomEndtime = 1
  plugin.tx_cal_controller.view.list.customStarttimeRelativeToGetdate = 1
  plugin.tx_cal_controller.view.list.customEndtimeRelativeToGetdate = 1
  plugin.tx_cal_controller.view.list.starttime = monthstart
  plugin.tx_cal_controller.view.list.endtime = monthend
[global]
// week-view: if (week=true && (weekday=0 OR weekday=1 OR weekday>1)) // weekday>0 doesnt worx at all
[globalVar = GP:tx_cal_controller|week >0]
  plugin.tx_cal_controller.view.list.useCustomEndtime = 1
  plugin.tx_cal_controller.view.list.customEndtimeRelativeToGetdate = 1
  plugin.tx_cal_controller.view.list.endtime = +1 week
[global]
// day-view: if (day=true && week=false (&& weekday=false))
[globalVar = GP:tx_cal_controller|day >0] && [globalVar = GP:tx_cal_controller|week <1]
  # hide ' - enddate' in header (startdate - enddate)
  plugin.tx_cal_controller.view.list.heading.2 >
[global]

// Month view
plugin.tx_cal_controller.view.month.monthMakeMiniCal = 1
plugin.tx_cal_controller.view.month.endPointCorrection = 9024000
plugin.tx_cal_controller.view.month.dayViewLink.prioriCalc >

现在您希望在当前视图中将 week-numbers 显示为 link 到本周或将 day-numbers 显示为 link 到今天。 由于 EXT:cal 版本 1.9 我需要 XCLASS 主控制器方法,为日、周、月、年、列表..视图设置 view-pid。

您将需要一个站点包扩展,在以下示例中 EXT:mysitepackage 最少包含以下文件:

  • Classes/Xclass/CalController.php
  • ext_localconf.php
  • ext_emconf.php
  • ext_icon.gif

Classes/Xclass/CalController 的内容。php

<?php
namespace Vendorname\Mysitepackage\Xclass;

/**
 * Extended main controller for calendar base
 *
 * @package TYPO3
 * @subpackage tx_mysitepackage
 * @copyright Copyright belongs to the respective authors
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
 */
class CalController extends \TYPO3\CMS\Cal\Controller\Controller {

    /**
     * Override main controller function that serves as the entry point from TYPO3.
     * 
     * @param array The content array
     * @param array The conf array
     * @return string of calendar data
     */
    public function main($content, $conf) {
        /**
         * Use dynamic viewPid for links in month-mini view (day, week, month, year), as used in \TYPO3\CMS\Cal\View\New[VIEW]View->get[VIEW]Link().
         * Fx: Each monthMini view has dayLinks. These links are only enabled, if [VIEW]ViewPid is set (should be set to current page id).
         * TS setup configuration for 'plugin.tx_cal_controller.view.[VIEW].[VIEW]ViewPid' is not stdWrap'able.
         * 
         * See TS:
         * plugin.tx_cal_controller.view.[VIEW].[VIEW]ViewPid = TEXT
         * plugin.tx_cal_controller.view.[VIEW].[VIEW]ViewPid.data = TSFE:id
         * plugin.tx_cal_controller.view.[VIEW].[VIEW]ViewPid.insertData = 1
         */
        // Day
        if ($conf ['view.'] ['day.'] ['dayViewPid.']) {
            $conf ['view.'] ['day.'] ['dayViewPid'] = $this->cObj->cObjGetSingle($conf ['view.'] ['day.'] ['dayViewPid'], $conf ['view.'] ['day.'] ['dayViewPid.']);
        }
        // Week
        if ($conf ['view.'] ['week.'] ['weekViewPid.']) {
            $conf ['view.'] ['week.'] ['weekViewPid'] = $this->cObj->cObjGetSingle($conf ['view.'] ['week.'] ['weekViewPid'], $conf ['view.'] ['week.'] ['weekViewPid.']);
        }
        // Month
        if ($conf ['view.'] ['month.'] ['monthViewPid.']) {
            $conf ['view.'] ['month.'] ['monthViewPid'] = $this->cObj->cObjGetSingle($conf ['view.'] ['month.'] ['monthViewPid'], $conf ['view.'] ['month.'] ['monthViewPid.']);
        }
        // Year
        if ($conf ['view.'] ['year.'] ['yearViewPid.']) {
            $conf ['view.'] ['year.'] ['yearViewPid'] = $this->cObj->cObjGetSingle($conf ['view.'] ['year.'] ['yearViewPid'], $conf ['view.'] ['year.'] ['yearViewPid.']);
        }
        return parent::main($content, $conf);
    }
}

ext_localconf.php

的内容
<?php
if (!defined ('TYPO3_MODE')) die ('Access denied.');

// XClass main controller class to adjust $conf. See EXT:mysitepackage/Classes/Xclass/CalController.php
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\CMS\Cal\Controller\Controller'] = array(
    'className' => 'Vendorname\Mysitepackage\Xclass\CalController',
);

安装并确保 Xclass 正常工作。然后您可以将以下错字配置添加到现有设置中:

/**
 * Xclass special
 *
 * Use dynamic viewPid for links in month-mini view (day, week, month, year), as used in \TYPO3\CMS\Cal\View\New[VIEW]View->get[VIEW]Link().
 * Fx: Each monthMini view has dayLinks. These links are only enabled, if [VIEW]ViewPid is set (should be set to current page id).
 * TS setup configuration for 'plugin.tx_cal_controller.view.[VIEW].[VIEW]ViewPid' is not stdWrap'able.
 *
 * XClass main controller class to adjust $conf. See EXT:mysitepackage/Classes/Xclass/CalController.php
 */
# day
plugin.tx_cal_controller.view.day.dayViewPid = TEXT
plugin.tx_cal_controller.view.day.dayViewPid.data = TSFE:id
plugin.tx_cal_controller.view.day.dayViewPid.insertData = 1
# week
plugin.tx_cal_controller.view.week.weekViewPid = TEXT
plugin.tx_cal_controller.view.week.weekViewPid.data = TSFE:id
plugin.tx_cal_controller.view.week.weekViewPid.insertData = 1
# month
plugin.tx_cal_controller.view.month.monthViewPid = TEXT
plugin.tx_cal_controller.view.month.monthViewPid.data = TSFE:id
plugin.tx_cal_controller.view.month.monthViewPid.insertData = 1
# year
plugin.tx_cal_controller.view.year.yearViewPid = TEXT
plugin.tx_cal_controller.view.year.yearViewPid.data = TSFE:id
plugin.tx_cal_controller.view.year.yearViewPid.insertData = 1

并且 month-view 中的所有数字都应该是 link,如果它包含有效的事件日期或时间段。

您将错过下个月或上个月的 link,这将保持当前 month-mini 和列表视图组合。 然后你需要调整一些模板。看看:

plugin.tx_cal_controller.view.month.monthMiniTemplate ###PREV_MONTHLINK######NEXT_MONTHLINK###.[=14 的标记=]

我可以在另一个问题中对此进行描述。