问题
I have been seeing the code of Calendar Base but I have not understood the way as work markers and its functionality in the code.
I want to know if is possible to create a mini calendar and in the moment that I click one day with events show below them the list.
Please guide me what is the way to resolve it, not give me a code.
回答1:
There are a lot of possible configurations for EXT:cal. I will only give the minimum required configurations for EXT:cal version 1.10.3 in TYPO3 CMS 7.6 as I used for one of my projects (not the sliding one, as mentioned i first comment).
You have installed EXT:cal and include static typoscripts ('Standard CSS-based template' and maybe 'Standard CSS styles').
At your calendar page in TYPO3 you create two contentelements of type plugin, where you choose 'TYPO3 calendar' as plugin. The first contentelement for month-mini-view, the second contentelement for list-view, with following configurations:
- Contentelement plugin month-mini-view:
Tab 'General settings' field 'Allowed views' select 'Month' only.
Tab 'Month view' field 'Display as a mini calendar' activate checkbox.
- Contentelement plugin list-view:
Tab 'General settings' field 'Allowed views' select 'List' and 'Single Event' in this order.
All other fields in plugin configuration are empty or has default value. I prefer, to not use field Record Storage Page, use typoscript 'plugin.tx_cal_controller.pidList' instead.
At frontend you should already see a month-mini and a list view.
Add following typoscript configuration (setup) to your page tree, which I found useful when using mont-mini and list view in combination:
// 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 >
Now you would like to get week-numbers as link to week period or day-numbers as link to this day in the current view. Since EXT:cal version 1.9 I need to XCLASS the main controller method, to set view-pid for day,week,month,year,list..view.
You will need a sitepackage extension, in the following example EXT:mysitepackage with minimum following files:
- Classes/Xclass/CalController.php
- ext_localconf.php
- ext_emconf.php
- ext_icon.gif
Content for 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);
}
}
Content for 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',
);
Install and ensure, that Xclass is working. Then you can add following typoscript configuration to existing setup:
/**
* 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
And all numbers in month-view should be a link, if it contains a valid event day or period.
You will miss a link to next or previous month, which will stay i current month-mini and list view combination. Then you need to adapt some templates. Have a look at:
plugin.tx_cal_controller.view.month.monthMiniTemplate and markers for ###PREV_MONTHLINK### and ###NEXT_MONTHLINK###.
I could describe this in an other question.
来源:https://stackoverflow.com/questions/41640057/how-mix-month-view-and-list-view-in-same-page-with-calendar-base-extension-in-ty