代码之家  ›  专栏  ›  技术社区  ›  Tig7r

使用SearchModuleBase将Ajax内容集成到DNN的搜索索引中的自定义模块中?

  •  0
  • Tig7r  · 技术社区  · 6 年前

    我想集成DNN的SearchModuleBase,以便自定义模块数据将显示在我们的自定义搜索结果模块中。

    我查看了SearchModuleBase Wiki和简介: http://www.dnnsoftware.com/wiki/modulesearchbase

    http://www.dnnsoftware.com/community-blog/cid/154913/integrating-with-search-introducing-modulesearchbase

    如何指定要DNN的爬网程序索引的确切内容? 例如:SKU、页面标题、产品描述?

    我看过的所有网站都使用了古老的ISearchable类: http://www.adefwebserver.com/dotnetnukehelp/ISearchable/

       public class ProductDetailedViewModuleBase : ModuleSearchBase
            {
                public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
                {
                    throw new NotImplementedException();
                }
            }
    

    我已将清单文件更改为可搜索。我不得不把I Searchable、I Portable和I Upgradeable改为Searchable、Portable和upgrade。

    enter image description here

    我也在尝试添加SearchModuleBase,但我遗漏了一些内容: enter image description here

    这是生成产品信息的前端代码: enter image description here

    2 回复  |  直到 6 年前
        1
  •  2
  •   zx485 potemkin    6 年前

    你的代码存根 GetModifiedSearchDocuments 就是这样。还没有完全实施。你必须更换 throw new NotImplementedException() 用代码填充 SearchDocument 您将返回的对象。这个 搜索文档 的属性是为要爬网程序索引的数据分配值的位置。

     public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
     {
         var searchDocs = new List<SearchDocument>();
         var productList = GetProductList();  //you write this method to return a list of your products
         foreach(var product in productList)
         {
             var searchDoc = new SearchDocument
             {
                 IsActive = true,
                 CultureCode = moduleInfo.CultureCode,
                 ...
                 Title = product.YourProductName,
                 Description = product.YourProductDescription,
                 Body = product.YourProductDescription,
             };
             searchDocs.Add(searchDoc);
         }
         return searchDocs;
     }
    

    你说:

    我也在尝试添加 SearchModuleBase

    我不知道你想完成什么,但是你不需要在那里做任何更改就可以得到自定义的内容索引。

        2
  •  2
  •   Fix It Scotty    6 年前

    您在清单中表示为 业务控制器类

    我应该看看这样的东西:

    namespace MyModule.Modules.ProductDetailedView.Components
    {
        public class FeatureController : ModuleSearchBase
        {
            public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
            {
                // TODO: convert your Product info object list to a SearchDocument object list and return
            }
        }
    }
    

    编译并实现此方法后,可以转到“设置”>“计划”并运行“网站爬虫程序”计划任务。将调试器附加到DNN进程,当任务执行时,应该命中GetModifiedSearchDocuments方法。

    有关此主题的示例代码的完整教程,您可以订阅 dnnhero.com my complete search tutorial .