列出具有至少一个常见标签的MODX文章

发布于 2025-01-25 23:37:44 字数 461 浏览 3 评论 0原文

是否可以使用getResources片段查找至少具有一个有效资源的常见标签的相关文章?

[[getResources? 
        &parents=`xxx, xxx` 
        &showHidden=`1` 
        &limit=`10` 
        &tpl=`relatedArticle-tpl`  
        &depth=`1` 
        &includeContent=`1`
        &includeTVs=`1`
        &processTVs=`1`
        &sortby=`publishedon`
        &tvFilters=`something here` 
]]

活动资​​源的电视[[*articletags]]至少应包含一个具有匹配资源的常见标签。

Is it possible to use the getResources snippet to find related articles that have at least one common tag with the active resource?

[[getResources? 
        &parents=`xxx, xxx` 
        &showHidden=`1` 
        &limit=`10` 
        &tpl=`relatedArticle-tpl`  
        &depth=`1` 
        &includeContent=`1`
        &includeTVs=`1`
        &processTVs=`1`
        &sortby=`publishedon`
        &tvFilters=`something here` 
]]

The TV [[*articletags]] of the active resource should contain at least one common tag with a matching resource.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凡间太子 2025-02-01 23:37:44

这就是我实施问题的方式:

[[getResources? 
    &parents=`x,x` 
    &showHidden=`1` 
    &limit=`10` 
    &tpl=`latestArticle`  
    &depth=`1` 
    &includeContent=`1`
    &includeTVs=`1`
    &resources=`-[[*id]]`
    &processTVs=`0`
    &sortby=`publishedon`
    &tvFilters=`[[tvFilterForRelatedArticles]]`
]]

制作电视过滤器的片段:

$tags = $modx->resource->getTVValue('articlestags');
$categories = $modx->resource->getTVValue('category');
$tagsArray = explode(",", $tags);
$categoriesArray = explode(",", $categories);
$result = "";
foreach ($tagsArray as $tag) 
    $result .= "articlestags==%".$tag."%||";
foreach ($categoriesArray as $category) 
    $result .= "category==%".$category."%||";
return substr($result, 0, -1);

不确定这是否是实现目标的最简单方法。如果有更好的解决方案,请随时发表评论。

This is the way how I implemented question:

[[getResources? 
    &parents=`x,x` 
    &showHidden=`1` 
    &limit=`10` 
    &tpl=`latestArticle`  
    &depth=`1` 
    &includeContent=`1`
    &includeTVs=`1`
    &resources=`-[[*id]]`
    &processTVs=`0`
    &sortby=`publishedon`
    &tvFilters=`[[tvFilterForRelatedArticles]]`
]]

And the snippet to make a TV filter:

$tags = $modx->resource->getTVValue('articlestags');
$categories = $modx->resource->getTVValue('category');
$tagsArray = explode(",", $tags);
$categoriesArray = explode(",", $categories);
$result = "";
foreach ($tagsArray as $tag) 
    $result .= "articlestags==%".$tag."%||";
foreach ($categoriesArray as $category) 
    $result .= "category==%".$category."%||";
return substr($result, 0, -1);

Not sure if this is the simplest way to achieve my target. Feel free to comment if there is a better solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文