0
votes

I am trying to Implement the ISearchable on one of our modules.

Visual Studio is indicating that SearchItemInfo is Obsolete and Deprecated in DNN 7.1.

I found this article, but it does show the new alternative code which I must use and there is so many internal functions on GitHub.

https://www.dnnsoftware.com/answers/searchdatastorecontroller-is-obsolete-in-71

 public SearchItemInfoCollection 
 GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
{
    SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();

    List<TestModuleInfo> colTestModules = GetTestModules(ModInfo.ModuleID);

    foreach (TestModuleInfo objTestModule in colTestModules)
    {
        SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objTestModule.Content, objTestModule.CreatedByUser, objTestModule.CreatedDate, ModInfo.ModuleID, objTestModule.ItemId.ToString(), objTestModule.Content, "ItemId=" + objTestModule.ItemId.ToString());
        SearchItemCollection.Add(SearchItem);
    }

    return SearchItemCollection;

    throw new System.NotImplementedException("The method or operation is not implemented.");
}

I did try to write the following method and attached a breakpoint on GetModifiedSearchDocuments and Scheduled the Site Crawler to crawl the site, but it is never hit. Also, by implementing this code, will this show the checkbox on the module which will enable you to turn ISearchable on and off?

//uncomment the interfaces to add the support.
public class FeatureController : ModuleSearchBase
{

    public CommonDataDefinitions.Products.WebProductDetails ProductDetails { get; set; } = null;


    public override IList<SearchDocument> GetModifiedSearchDocuments(ModuleInfo moduleInfo, DateTime beginDateUtc)
    {
        var searchDocs = new List<SearchDocument>();
        var products = new List<QuickProduct>
        {
            new QuickProduct("CT4455", "Soundbar", "The soundbar is used for entertainment purposes." ),
            new QuickProduct("BD5333", "Laser Pointer", "For Presentations." )
        };

        foreach (var product in products)
        {
            var searchDoc = new SearchDocument
            {
                IsActive = true,
                CultureCode = moduleInfo.CultureCode,
                Title = product.Title,
                Description = product.Description,
                Body = product.Description,
            };
            searchDocs.Add(searchDoc);
        }
        return searchDocs;
    }

}

public class QuickProduct
{
    public string SKU { get; set; }

    public string Title{ get; set; }

    public string Description { get; set; }

    public QuickProduct(string SKU, string Title, string Description)
    {
        this.SKU = SKU;
        this.Title = Title;
        this.Description = Description;
    }
}
1

1 Answers

1
votes

The easiest way to get an idea how these interfaces are implemented is always to have a look at the source code of a module where it works, and a very good starting point is the HtmlText module included in DNN. See here.

I vaguely remember that the module is marked as Searchable (etc.) during the installation process, therefore you have to create an upgrade package and install it to take it in effect.

Another way (for development or testing installations) could be to do that directly in the database, table DesktopModules, column SupportedFeatures. Values are:

1 = Portable
2 = Searchable
4 = Upgradeable

To combine two features, add the numbers, eg. Portable and Searchable = 3, All = 7 etc.

After updating this column restart the application pool to take this into effect.

NOTE: I only recommend this for development or testing environments. In production environments you should use a package to upgrade the extension.