だから、基本的には、セグメントのパターンを調べる必要があり、それがパターンと一致しない場合は、カテゴリ(seg2cat経由)でエントリーループを開始します。
{segment_2}
が日付の場合は、 YYYY-MM
または YYYY-MM-DD
のいずれかになります。
<?php
$this->EE =& get_instance();
$seg2 = $this->EE->uri->segment(2);
$date_pattern_half = '/^[0-9]{4}-(0[1-9]|1[0-2])$/';
$date_pattern_full = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/';
if( preg_match($date_pattern_full, $seg2) || preg_match($date_pattern_half, $seg2) ) {
?>
{exp:low_events:entries channel="calendar" date="{segment_2}"}
<?php } else { ?>
{exp:low_events:entries channel="calendar" category="{segment_2_category_id}"}
<?php } ?>
... do stuff with entries here ...
{/exp:low_events:entries}
戻ってくるエラーは次のとおりです。
構文解析エラー:予期しない '}' /server/domain/system/expressionengine/libraries/Functions.php(679):eval() '68行目のコード
参考までに、Functions.phpの上記の関数は次のとおりです:
/**
* eval()
*
* Evaluates a string as PHP
*
* @access public
* @param string
* @return mixed
*/
function evaluate($str)
{
return eval('?'.'>'.$str.'<?php ');
}
As for the 'line 68' val it's just a closing
tag.
オープニングループ( {exp:low_events:entries}
)を削除しても、このエラーは発生しません。
代わりの構文 <?php else:?>
などを試しましたが、上記の代わりに予期しないT_ELSE
があります。