Deleting parent page

Permalink
I have a client that is using the real estate engine. They have lots of listings that basically live under the main Listings page. Their site admin deleted the main Listings page, so now all of the pages that were created under it are now missing from the Full Sitemap. They thought they had deleted all of their listings since they weren't showing up in the Full Sitemap. I informed them that the pages still exist and they can find them in the Page Search section if they search for the Real Estate Listing page type.

I'm wondering how to get those pages to live again in the Full Sitemap without having to go to each page under the Page Search to move it's location.

I didn't post this in the Real Estate package section since I didn't think it was specific to the engine.

Thanks!

FatTony1952
 
olliephillips replied on at Permalink Reply
olliephillips
Would be a great feature for Page Search | With Selected but you can't do it as far as I know via the Dashboard currently.

Instead (if you can't restore from database backup) I think you'll need to write code that gets all the listings based on their pagetype, and then assigns each of them to a new parent which you manually create with the Real_Estate_Listings page type.

Lifted from the docs, the code to get the pages using a page type is:

$pageType = CollectionType::getByHandle($handle)
$pages = $pageType->getPages()


The code to move the pages is this:

$page->move(Page $newParent)


You'd loop through all the page objects in $pages assigning them to a new parent which is done on id (I think).

Hope that helps
jordanlev replied on at Permalink Reply
jordanlev
Wait, deleting a parent page does *not* actually remove children pages from the site?!?! Aye carumba! I have many a time done mass deletions by deleting parent pages, fully expecting all children pages to go away too. Do you know if those orphaned pages would come up in a site search or the sitemap.xml file?

I really wish deleting pages was just another version in the version history, then it wouldn't matter what did or didn't get deleted. Maybe in version 5.8? ;)

By the way, despite my annoyance at this bizarre and undocumented behaviour, I am glad that in your case it didn't result in massive data loss.

-Jordan
FatTony1952 replied on at Permalink Reply
FatTony1952
Haha @ jordanlev! I had gotten a call from the client in a panic. She was trying to delete a page, her browser got hung up, she refreshed the page or something and her parent page with all of her sub-pages were gone from the Full Sitemap. I immediately went to the Page Search to see if I could find them and they were all there. I'm not sure how she managed to get rid of all of them from the Full Sitemap. I re-created the parent page with the same page name as the deleted page assuming that using the same path would magically make them reappear, but I guess it's done by the page's ID number instead.

I will check the sitemap.xml file (assuming nothing ever gets technically deleted from there?) to see if they're still there. Does the Full Sitemap actually pull from that xml file?

@ollie - I will trial and error your suggestion. That sounds like it just might work.
jordanlev replied on at Permalink Reply
jordanlev
No the full sitemap does not pull from sitemap.xml. sitemap.xml is generated by the system, so it is only the end result of a "job" that runs (via Dashboard -> System & MAintenance) -- and it is only used to help google index your site better -- which is why I would worry about deleted pages staying in that file because I wouldn't want google to index them (in my case where I actually *did* want to delete the pages).
drumrby replied on at Permalink Reply
drumrby
Can you please tell me how you corrected this issue. One of my clients did the exact same thing, and I'm not sure how to fix the situation. Thank you in advance.
FatTony1952 replied on at Permalink Reply
FatTony1952
I got a daily database backup from my server host and just replaced it to an earlier version of the site.