Script for Finding Pages Based on Linked Files

Overview

 

This article furnishes a script to provide a quick way to view all the pages where certain types of files are currently linked. An example of where this might be useful would be when you need to update all links because a file name has changed.

 

Information

 

Producing a list of all pages, which contain specific files, can be accomplished with the following database script:

 

SELECT pa.HTTPAlias, REPLACE(t.TabPath, '//', '/'), ht.content
FROM Tabs T
INNER JOIN portalalias pa ON t.PortalId = pa.PortalID
INNER JOIN tabmodules tm on tm.tabid = t.tabid
INNER JOIN htmltext ht on ht.moduleid = tm.moduleid
WHERE ht.Content LIKE '%.pdf%';

 

This script looks into the HTMLText table, which stores content from HTML modules, and searches for links with the specified extension.

  • In this case, it is .pdf, but you can change that value on the last line to another extension as needed (i.e. '%.docx%')

 

The script then takes the page containing the module and appends it to the portal alias to generate a full URL for the page where the link resides.

Lastly, it provides a copy of the HTML module content itself, which you will need to review and confirm it matches your expectations.

 

Additional Information

 

Comments

0 comments

Please sign in to leave a comment.