Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[Solved] How do I renew/update all url_titles in database?
Hello,
maybe a little bit strange question but understandable together with this thread.
Theoretically I should clear the url_title field for all articles in database and after that, force textpattern to resave all these articles what implements a regeneration of the permlink urls. So, the question is (I did not search in source code), how the save function in textpattern is named, which I have to call to proper update all permlinks.
Thanks in advance …
Last edited by whocarez (2010-08-26 20:24:45)
Offline
Re: [Solved] How do I renew/update all url_titles in database?
Running simple SQL query is best for mass updating. Anyhow, TXP’s core doesn’t have loop-updating function, but just the normal updating/saving function. When you just want to update one field, you probably don’t need to run the whole deal (but ofcourse you can call it multiple times in a row if you want).
You can do exact same regular expressions, as with PHP, and whatnot with just a single MySQL query. See the list of string functions MySQL offers.
For example:
update textpattern set url_title=replace(lower(Title),' ','-') where foo='bar'
Don’t run it as it is. It’s just an example. Might bork something :-)
Altho, if you want to do it with PHP, you can do that too:
$rs =
safe_rows(
'Title',
'textpattern',
'1=1'
);
foreach($rs as $a)
safe_update(
'textpattern',
"url_title='".sanitizeForUrl($a['Title'])."'",
"Title='".doSlash($a['Title'])."'"
);
Remember to include the resource files (or use the code it in correct context) or it won’t work.
Last edited by Gocom (2010-08-25 18:36:30)
Offline
Re: [Solved] How do I renew/update all url_titles in database?
Thanks a lot once again …
I didn´t need my backup :-D …
Offline