mareike
Returning Observer

Replace all Usages of a PageRef with another PageRef

Hello there,

we want to delete some PageRefs and replace all usages of these PageRefs with another PageRef. As they have a lot of usages it is a lot of manual work. So is there a simple way to exchange all usages with a script or something like that? Would be really useful! 

Best,
Mareike

2 Replies
mbergmann
Crownpeak employee

Hi Mareike, 

if your intention would just be to "replace" an old PageRef with a (new) one, an idea would be to keep the exsting one but let it point to another content page (green) and just move the PageRef to the "new" location - but I assume that's not your use case... or might this also be an option?

If not: To my knowledge, there's no easy way to replace a PageRef just "everywhere".

Background: You would have to iterate not only into pages and sections but also into INPUT_DOMs (inline links), FS_CATALOGs (and their inner DOMs) and change all their FormData (change the value of all FS_REFERENCE's) so there would be quite some cases to handle. 

Depending on "where most of those PageRefs [more precisely: The FS_REFERENCES] are": Iterating through pages/sections and replace the PageRef in those FS_REFERENCES that are "at the top level form" (=page templates and section templates) should be quite easy/generic. So it might be an approach to start with those "simple" cases.

Michael

0 Kudos

Hi Michael,

thanks for your reply. Using the old PageRef and reference another page is not an option here because multiple pages get replaced by one new page and the old urls should be completely deleted (we also want to tidy up our PageRefs).

Sadly, many of the FS_REFERENCES are inside INPUT_DOMS and FS_CATALOGS. If someone has a script or a script for a similar use case it would be really helpful to post it here so we don't have to start from scratch.

Mareike

0 Kudos