How to find instance of block or page in CMS

Vote:
 

The title is self explanatory. As an example, let's say i have a FooBlock and a FooPage. How do I find all instances of the FooBlock and the FooPage in the CMS? Searching for the FooBlock in the assets pane and the FooPage in the navigation pane does not yield any results.

#186086
Dec 12, 2017 10:01
Vote:
 

If you want that kind of functionality in the editor i think you will have to index the classname to the search index yourself.

Implementation would vary depending on search provider. undecided

#186100
Dec 12, 2017 14:37
Vote:
 

this should be what you're after

var contentTypeRepository= ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var modelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();

var blockType= contentTypeRepository.Load(typeof(BLOCKTYPE));

var items = modelUsage.ListContentOfContentType(blockType);


then use contentlink property on each of the items to get a reference to all the blocks/pages of that type.

#186101
Dec 12, 2017 14:39
Vote:
 

I ment through the editor interface. Sorry if I was unclear.

#186104
Dec 12, 2017 14:41
Vote:
 

I would yeild caution on contentModelUsage as I think this queries the database instead of cache.  My fellow collegues might know the answer about the database quering but I am pretty sure it does.

#186105
Dec 12, 2017 14:43
Vote:
 

Sorry for the misunderstanding.

I am not sure you can without using episerver find or writing your own module to do so.  EPiServer find has "Power Slice" but you will need to have a find license.

#186106
Dec 12, 2017 14:45
Vote:
 

you do something as follows

 [Component(PlugInAreas = "/episerver/cms/assets", Categories = "cms", WidgetType = "modeltypesearch/modelsearch", Title = "Content Type Search", Description = "")]
    [ServiceConfiguration(typeof(IContentQuery))]
  public class ModelTypeSearchComponent : ContentQueryBase
    {
  public override string Name
        {
            get { return "CustomQuery"; }
        }

        protected override IEnumerable<IContent> GetContent(ContentQueryParameters parameters)
        {
/ /Enter code above based on input to search for type.
}
}
<div>
    <div class="epi-gadgetInnerToolbar" data-dojo-attach-point="toolbar">
        <div data-dojo-type="dijit.form.TextBox" data-dojo-attach-point="queryText" data-dojo-props="intermediateChanges:true" data-dojo-attach-event="onChange: _reloadQuery"></div>
    </div>
    <div data-dojo-type="epi.cms.component.ContentQueryGrid" data-dojo-attach-point="contentQuery"></div>
</div>

The above is your template for the module.

then in module config, add the following

<?xml version="1.0" encoding="utf-8"?>
<module>
  <assemblies>
    <add assembly="YourAssemblyName" />
  </assemblies>
  <dojoModules>
    <add name="modeltypesearch" path="ModeTypelSearch" />
  </dojoModules>
</module>

Give that a try. 
so   the template and code goes in   
/modules/ModelSearch/templates
/modules/ModelSearch/modeltypesearchcomponents.cs

#186109
Dec 12, 2017 14:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.