Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Peter Maslin 1 post 71 karma points
    25 days ago
    Peter  Maslin
    0

    Identifying where a Block is being used

    Hi

    we are using the block list option and have created a large number of blocks for our site to allow content editors to build various pages without developer input.

    one thing we have not been able to do is find a way to identify where or if a block is being used we have tried tools like diplo.godmode etc.

    but nothing we have found can give us a break down on where a block is being used, if we could produce a report somehow to show a blocks usage that would be great but any other tool/plugin would be useful.

    we are on umbraco 12 and use an on premises installation.

    Peter

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    24 days ago
    Marc Goodson
    0

    Hi Peter

    How have you setup the reusable blocks?

    Are they items in the content tree that the editors pick?

    So you have a 'Shared Content Block' and the editors pick a reusable content block from the tree? if so then this will create a Relation between the reusable block, and you can see where they are used on the 'info' tab of the reusable content item.

    eg

    enter image description here

    But if you are talking about the usage of 'Block Types', eg where has the Video Block Type been used, then, because that is stored in a big blob of JSON in the database for the Block List property editor it can be difficult to determine!

    If this is just a 'one off audit' - You can query the database umbracoPropertyData table, to look at the stored database for the Block List raw data and the ids of the different Element Types...

    or similarly if you have uSync installed you can export all the content of the site into XML files and search them...

    But if its for more of an ongoing thing, then you could create in the Relations section a new Relation Type called Block Type Usage.

    enter image description here

    This creates a place to store, ermm relations between DocTypes and Documents (content nodes).

    Then you could tap into the ContentService's notifications:

    https://docs.umbraco.com/umbraco-cms/reference/notifications/contentservice-notifications

    and handle the Saving event, see which blocks are on the page that is being saved, and use the RelationService to create a relation between them under the new relation type

    https://docs.umbraco.com/umbraco-cms/reference/management/services/relationservice

    similarly for the deleting event, removing any relations...

    Then you could build a custom dashboard, https://docs.umbraco.com/umbraco-cms/tutorials/creating-a-custom-dashboard that used the RelationService to pull back all the relations from the Relation Type and group together by 'Document Type' listing all the content items that use that particular Doc Type!

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft