Problems, need help? Have a tip or advice? Post it here.
7 posts Page 1 of 1
Hi,

I erased many pages on a website, but the pages are still appearing in the database, but without content.

Like if I do a search for https://paologallery.com/search/?s=dali&nc=1
it shows me all the pages for "Dali" that were there, but no longer exist.

BUT nothing appears in Admin anymore, so I can't erase them again.

Is there any solution for cleaning the DB, and erasing all empty pages, beside resting the website anew, or manually erasing in the DB itself?

Thanks for your help.
Search is based on <cms:pages> tag internally, it means that pages can be requested by this tag. A sure way to delete them from database (plus all their fields data and fulltext) is to use this code:

Code: Select all
<cms:pages masterpage="" 
    skip_custom_fields='1'
    show_unpublished='1'
    show_future_entries='1' 
    limit='1000000'
    ><cms:db_delete masterpage=k_template_name page_id=k_page_id invalidate_cache='1'/>
</cms:pages>
It actually erased everything, including the valid pages.

I should have thought before, and go with:

Code: Select all
<cms:if gg_image = ''>
    <cms:db_delete masterpage=k_template_name page_id=k_page_id invalidate_cache='1'/>
    </cms:if>


But hey, thanks, anyway.
It actually erased everything, included the valid pages.

I hope (actually, I am sure) you have a database backup, Paolo.
After restoring, try deleting the pages manually the same way you did originally and if the same issue crops up again, please PM me the access creds for the site and I'll take a look at the problem.
Hey, it worked :)

Paolo, I am sorry for your loss (hope you have a backup). I should have posted a big red alert along the code. Here is the version that fetches pages with empty image

Code: Select all
<!-- this code deletes ALL PAGES where "gg_image" is empty within a given masterpage -->
<cms:pages masterpage=""
    custom_field="gg_image=="
    skip_custom_fields='1'
    show_unpublished='1'
    show_future_entries='1' 
    limit='1000000'
    ><cms:db_delete masterpage=k_template_name page_id=k_page_id invalidate_cache='1'/>
    <cms:no_results><h3>Completed successfully</h3></cms:no_results>
</cms:pages>
Don't bother Trendoman, I didn't actually made a backup recently because there was only like 10 pages.

Thanks for the code, that was very helpful.

I haven't developed anything for a while, so, even if Couch stays my favorite CMS, I am a bit rusty.
I never learned the db_delete function anyway... :D

You guys have a wonderful day, and thanks again for the help.
Paolo
PaoloE wrote: I haven't developed anything for a while


You can still play with Couch. It is a respected hobby that keeps brain in shape :)
7 posts Page 1 of 1