Copied to clipboard

Flag this post as spam?

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


  • Jeremy Schlosser 14 posts 145 karma points
    Jul 25, 2024 @ 17:36
    Jeremy Schlosser
    0

    Upgrading to Umbraco Version 14: Finding Macros

    Does anyone have a DB query or another method to identify nodes that are using macros in version 13? I'm in the process of moving all macro content to Blocks, but finding every instance of every macro partial file requires opening and checking each node and we have a couple thousand nodes in our site.

  • Ayo Adesina 445 posts 1059 karma points
    Jul 29, 2024 @ 22:18
    Ayo Adesina
    0

    Not sure how I would do it directly in the database.

    But maybe you could use the Umbraco API to query every single node, and and then loops through every single property looking for a RTE to narrow it down.

    Print the Ids of the nodes to the screen or logs.

    Did you solve this problem yet? would be intrested to know how you approached it.

  • Jeremy Schlosser 14 posts 145 karma points
    Jul 31, 2024 @ 00:18
    Jeremy Schlosser
    0

    No luck yet. I tried doing what Ayo described in a Razor view, querying every single node, focusing on one property, and then seeing if that property contains "UMBRACO_MACRO," but Umbraco keeps throwing IPublishedContent does not contain a definition for 'Contains'...

    child.Value<IEnumerable<IPublishedContent>>(myPropertyToSearch).Contains("UMBRACO_MACRO")
    
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 31, 2024 @ 08:31
    Lee Kelleher
    1

    Hi Jeremy, here's a SQL query you could try directly on the database...

    SELECT
        n.id AS [nodeId],
        n.path AS [path],
        n.text AS [nodeName],
        pd.textValue AS [propertyData]
    FROM
        umbracoNode AS n INNER JOIN
        umbracoDocument AS d ON d.nodeId = n.id INNER JOIN
        umbracoContent AS c ON c.nodeId = n.id INNER JOIN
        cmsPropertyType AS pt ON pt.contentTypeId = c.contentTypeId INNER JOIN
        umbracoPropertyData AS pd ON pd.propertyTypeId = pt.id
    WHERE
        (d.published = 1 OR d.edited = 1) AND
        pt.Alias = 'myPropertyToSearch' AND
        pd.textValue LIKE '%UMBRACO_MACRO%'
    ORDER BY
        n.id ASC
    ;
    

    Hope this helps; feel free to tweak they query as you need.

    Cheers,
    - Lee

  • Jeremy Schlosser 14 posts 145 karma points
    Jul 31, 2024 @ 22:18
    Jeremy Schlosser
    100

    Thanks Lee, that was helpful. With some tweaking (Thanks to my colleague) it did the job.

    SELECT n.id NodeId
    , n.level NodeLevel
    , n.path NodePath
    , n.text NodeText
    --, cv.text
    , pt.Alias PropertyTypeAlias
    , pd.textValue PropertyDataTextValue
    , (
    SELECT REPLACE(SUBSTRING(pd.textValue, (SELECT CHARINDEX('macroAlias=', pd.textValue)),30), 'macroAlias=', '')
    ) MacroAliasText
    FROM dbo.umbracoPropertyData pd
        INNER JOIN dbo.cmsPropertyType pt ON pt.id = pd.propertytypeid
        INNER JOIN dbo.umbracoContentVersion cv ON cv.id = pd.versionId
        INNER JOIN dbo.umbracoNode n ON n.id = cv.nodeId
    WHERE pt.Alias = 'myPropertyToSearch' 
        AND cv.[current] = 1
        AND pd.textValue LIKE '%UMBRACO_MACRO%'
    
    ORDER BY [NodePath], [NodeId]
    
Please Sign in or register to post replies

Write your reply to:

Draft