Hello,
how can I get the alternate url field value (page's option tab) just before save it in db?
My goal is to make a UDT that, in conjunction with the ContentEditPre event, does:
1) queries the cms_content table and stores in a variable the value of the page_url field
2) gets the new Page URL value (alternate url in option tab)
2) queries a custom db table to see if there are duplicates entries for that url
3) if there are not, inserts the url in the custom table and update the .htaccess file with a 301 status, redirecting the old url to the new one
I'm using cmsms 1.10.3
thanks
Get page_url value before update it in db
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Get page_url value before update it in db
The Content object attached to the ContentEditPre event already contains the values that were either calculated or entered by the user. The old data (before the change) is not included.
Your event handler could 'query' the content table for the appropriate content id and extract the page_url field.
i.e:
And BTW. Please do not write to the CMSMS content tables etc. or the tables of any other module. Go ahead and read whatever you want, but writing to the database of another module or the core may lead to problems.
Your event handler could 'query' the content table for the appropriate content id and extract the page_url field.
i.e:
Code: Select all
$content_obj = $params['content'];
$query = 'SELECT page_url FROM '.cms_db_prefix().'content WHERE content_id = ?';
$old_url = $db->GetOne($query,array($content->Id());
$new_url = $content_obj->URL();
if( $old_url != $new_url ) {
// ... do your stuff ....
}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.