Jump to content

How to renew / regenerate pagenames for all pages?


sebibu
 Share

Recommended Posts

I discovered a bug in the pagename generation, see here:
https://processwire.com/talk/topic/30444-prepend-date-in-page-name-by-hook-creates-improper-results-on-some-existing-pages/

If there is a final fix, I need to renew / regenerate pagenames out of all pagetitles for all pages of a website.
How would you do this?
Is there a GUI-way? Or via API with a foreach? With the help of RockMigrations?

One pinch: All news pagenames should still be prepended with my hook listed in the forum topic above.

Thanks in advance!

Link to comment
Share on other sites

A very good hint to use TracyDebugger's console for that, @bernhard!

Unfortunately in my tests the pagename is not renewed (or new set if empty) out of the pagetitle!

foreach($pages->find("template!=admin, has_parent!=2, include=all") as $p) {
  $p->save();
  echo "Page {$page->title} (#$p) updated to {$p->name}<br>";
}

Any idea?๐Ÿ‘‹

Link to comment
Share on other sites

First thing to check is if your hook gets executed. For that put this at the very top of your hook:

d('fired');

You should see these dumps in the console output when you foreach() and save()

If you don't see it, your hook does not get triggered, which means you found the reason why the page name does not update.

Link to comment
Share on other sites

Thanks @bernhard! After shutting down the pc yesterday I got the cause.
All pages without news template do not have a saveReady-hook.
So for renewing pagenames on pages with other templates I simply have to temporarily create a new hook to set the pagename for other templates, too.
Without the prepended news-published-day. Seems to work!โ˜บ๏ธ๐Ÿ™๐Ÿ™‹โ€โ™‚๏ธ

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
ร—
ร—
  • Create New...