-1

Good afternoon,

Due to a recent but necessary CSS change, we need to find all instances of our only WFFM form across all 500 websites in our solution.

I am looking for a powershell script to identify all pages that contain the WFFM so we can more easily audit the CSS issue.

If it could also list what placeholder the form is in that would be ideal as the CSS issue only affects certain areas.

Thanks!

Sitecore.NET 8.1 (rev. 160519) Web Forms for Marketers 8.1.rev. 160523

2

The script below should do the trick.

I don't remember what's the id of the WFFM Form rendering so best check in your website and assign it to formRenderingId variable.

The script takes all descendants of the $root and if $formId can be found in either __Renderings or __Final Renderings it fires regexes to find placeholder key before or after the rendering id in rendering part (<r...) of the xml, e.g.

<r id="{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}" 
   ph="content" 
   uid="{73F42C30-9FF1-4958-9107-5A5ED0C4E41C}" />
<r ph="content" 
   uid="{11111111-9FF1-4958-9107-5A5ED0C4E41C}"
   id="{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}" />

Both are valid xmls but ph sometimes is before and sometimes is after the id, that's why I needed 2 regexes.

$formRenderingId = "{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}"
$root = "master:/content"

$phRegexPart = "[^>]*ph=`"(?<Placeholder>[^`"]+)`"[^>]*"
$formRenderingIdRegexPart = "[^>]*\" + $formRenderingId + "[^>]*"
$regex1 = ("\<r" + $formRenderingIdRegexPart + $phRegexPart)
$regex2 = ("\<r" + $phRegexPart + $formRenderingIdRegexPart)
$like = ("*" + $formRenderingId + "*")

$rootItem = Get-Item -Path $root
$descendants = $rootItem.Axes.GetDescendants()
foreach ($descendant in $descendants) {
    $renderings = ""
    if ($descendant["__Renderings"] -like $like) {
        $renderings = $descendant["__Renderings"]
    }
    if ($descendant["__Final Renderings"] -like $like) {
        $renderings = $descendant["__Final Renderings"]
    }
    if ($renderings -match $regex1) {
        $ph = $matches.Placeholder
        $descendant.Paths.FullPath + " " + $ph
    }
    if ($renderings -match $regex2) {
        $ph = $matches.Placeholder
        $descendant.Paths.FullPath + " " + $ph
    }
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.