Finding out the pages where an FMS file is used
A question that comes up commonly is how to find out the pages where a digital asset (a FMS file) is used.
There are two ways to retrieve this information:
a) Using the ShadoCMS API: Searches the database
b) Using the Lucene search: Full-text, indexed search
Both approaches are explained below.
Using ShadoCMS API
You can use the code below to find out where a digital asset (an FMS file) is being used. You'd need to provide the UUID of the file to search, and the code returns a query containing information about the page on which FMS file was located. For large sites, with lots of contents, this can be very resource-intensive.
<cfset oContainers = createObject("component","shadomx.core.containers.shado_obj_containers")>
<cfset oQuery = createObject("component","shadomx.core.queries.shadoquery")>
<cfset uFile = "8402E3BF-9482-DB8B-50CD-11EA5CC7D1EA"> <!--- UUID of the file to search for. Change it to the one you need to search for --->
<!--- Get all containers that contain the UUID of the FMS file. This can be quite resource-intensive --->
<cfset qActiveContainers = oContainers.getAllActiveContainers(filter="8402E3BF-9482-DB8B-50CD-11EA5CC7D1EA")>
<!--- Loop over the containers and figure out pages on which the container is used --->
<cfloop query="qActiveContainers">
<!--- First we get container info so that we can get hold of the page the container belongs to --->
<cfset qContainer = oQuery.getObjectInfo( object_uuid = qActiveContainers.container_uuid,
object_type = "Container"
)>
<!--- Then lets get page information --->
<cfset qPage = oQuery.getObjectInfo( object_uuid = qContainer.object_parent_uuid,
object_type = "Page"
)>
<cfdump var="#qPage#" label="Page">
</cfloop>
Using Lucene Search
From ShadoCMS 8.0 onwards, you can also use the built-in Lucene search to search for files. Simply create a store for the site tree, and search for the UUID of the FMS file that you need to locate. You can also use the file title to search for the file as well. This approach works very well with large sites, that have lots of content. However, for this to work, you do need to index/reindex the site tree. And also, this approach returns only those files that are used on pages and sections marked as searchable will be shown in the results.
Comments
There are no comments for this page as yet.
print page
