我正在使用Piranha Core 8和Aspnetcore 3。到目前为止一切都很顺利。(我爱皮拉尼亚!)我当前的问题是,当构建一个包含类别列表的侧栏时。我不知道如何从Api中检索所有类别的。
到目前为止,我可以得到一个帖子列表,也许可以迭代它们来收集类别,但这似乎是没有效率的。
谁知道如何从cshtml页面检索所有类别的列表?
发布于 2020-01-13 07:43:46
您可以通过调用Api获得每个档案馆分类的完整列表。
var categories = await api.GetAllCategoriesAsync(archiveId);
var tags = await api.GetAllTagsAsync(archiveId);诚挚的问候
发布于 2021-10-24 15:22:01
从剃须刀那页我发现它是这样运作的:
@{
var archiveId = WebApp.CurrentPost == null ? WebApp.CurrentPage.Id : WebApp.CurrentPost.BlogId;
var categories = await WebApp.Api.Posts.GetAllCategoriesAsync(archiveId);
var tags = await WebApp.Api.Posts.GetAllTagsAsync(archiveId);
}https://stackoverflow.com/questions/59700245
复制相似问题