2 Commits

Author SHA1 Message Date
zhangf@suq.cn e7900a7749 Merge remote-tracking branch 'origin/master' 1 week ago
zhangf@suq.cn 5552f530da feat(taglib): 支持模板变量作为内容ID参数 1 week ago
  1. 12
      app/taglib/HcTaglib.php

12
app/taglib/HcTaglib.php

@ -690,7 +690,13 @@ parse;
*/ */
public function tagContentPage($tag, $content): string public function tagContentPage($tag, $content): string
{ {
$cid = !empty($_GET['cid']) ? $_GET['cid'] : (empty($tag['cid']) ? '' : (int)$tag['cid']);
$cid = !empty($_GET['cid']) ? (int)$_GET['cid'] : (empty($tag['cid']) ? '' : $tag['cid']);
if (strpos($cid, '$') === 0) {
// cid 为模板变量(如 cid="$ui_invest_learn"),运行时解析
$this->autoBuildVar($cid);
} else {
$cid = (int)$cid;
}
$keywords = empty($_GET['keywords']) ? '' : $_GET['keywords']; $keywords = empty($_GET['keywords']) ? '' : $_GET['keywords'];
$item = empty($tag['item']) ? 'vo' : $tag['item']; $item = empty($tag['item']) ? 'vo' : $tag['item'];
$mainField = empty($tag['mainField']) ? '*' : $tag['mainField']; $mainField = empty($tag['mainField']) ? '*' : $tag['mainField'];
@ -715,7 +721,7 @@ parse;
$parse = <<<parse $parse = <<<parse
<?php <?php
\${$returnVarName} = \app\service\ContentService::tagContentPage([ \${$returnVarName} = \app\service\ContentService::tagContentPage([
'cid' => '{$cid}',
'cid' => {$cid},
'item' => '{$item}', 'item' => '{$item}',
'mainField' => '{$mainField}', 'mainField' => '{$mainField}',
'subField' => '{$subField}', 'subField' => '{$subField}',
@ -741,7 +747,7 @@ parse;
$parse = <<<parse $parse = <<<parse
<?php <?php
\${$returnVarName} = \app\service\ContentService::tagContentPage([ \${$returnVarName} = \app\service\ContentService::tagContentPage([
'cid' => '{$cid}',
'cid' => {$cid},
'item' => '{$item}', 'item' => '{$item}',
'mainField' => '{$mainField}', 'mainField' => '{$mainField}',
'subField' => '{$subField}', 'subField' => '{$subField}',

Loading…
Cancel
Save