Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
How to update all articles URL ?
Hello,
is there’s a way, or a plugin, to clean the url title field of all the articles in a site ?
It is manually possible with the advanced option of each article, but when a site came in production, it will be a good think to “initialize” all articles’ url.
Thanks for all your ideas !
françois
Offline
#2 2009-02-17 00:35:22
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How to update all articles URL ?
…a good think to “initialize” all articles’ url.
Er, I don’t understand. Why would you need article url titles to be re-generated en-masse?
Offline
Re: How to update all articles URL ?
Hello Mary,
well : when you work on a new web site :
- you add articles -> url titles are created
- you try to refine your site content with more appropriated titles, you modify some articles titles -> some url titles are now wrong with the real title of your articles
- and sometimes, you create a new article with the same name as an old one -> you have 2 articles with the same url title
It’s probably rare but a customer have made this manipulation 2 times and was surprised to see that 2 articles opened a single article.
So my needed was to clear all url title when I put a site in production, after a lot of articles name changing.
Last edited by fpradignac (2009-02-17 05:59:36)
françois
Offline
#4 2009-02-17 12:46:00
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: How to update all articles URL ?
Well if you clear the url title field when you’re actually changing the article title, it will re-generate it at that point (which makes sense bcause you’ve got the article open in the write tab anyway).
After the fact, however, there’s no way of doing this that I know of. A plugin could do it, but I don’t know if one has been written.
Offline
Re: How to update all articles URL ?
Thanks Mary : I uses another CMS (SPIP) that have a plugin to do the trick on the whole site.
Perhaps I’ll take the time to look at this plugin : if you have an idea to begin it ;-)
françois
Offline
Re: How to update all articles URL ?
What you’ll need to do is select the titles of all articles, then update the url_field with stripSpace($row['Title'])
. Something like this may work (untested, and I haven’t had breakfast yet):
<txp:php>
$rs = safe_column('Title', 'textpattern', 'Status = 4');
if ($rs)
{
foreach ($rs as $row)
{
safe_update('textpattern', 'Title = "' . stripSpace($row['Title']) . '"',
'Title = "' . $row['Title'] . '"');
}
}
</txp:php>
Offline
Re: How to update all articles URL ?
Hmmm ! Thanks a lot jm !
I’ll have a look soon.
françois
Offline
Re: How to update all articles URL ?
Before making a pluging, I’ve tested that, hacking the txp_list.php file, after line 361 :
'reseturltitle' => 'Reset the URL title',
and after line 491 :
case 'reseturltitle':
$recID = $item[‘ID’]; $recTitle = safe_field(‘Title’, ‘textpattern’, “ID = $recID”);
$key = ‘url_title’; $val = stripSpace($recTitle);
break;
and here’s is the result : it’s more subtil than my first idea which were to reset all articles.
Second time : create a plugin :-( … prd_reset_url
Last edited by fpradignac (2009-02-17 21:40:47)
françois
Offline
Re: How to update all articles URL ?
Is there’s a way to override a core function with a plugin, instead of hacking it ?
Here, as mentionned above, I want to add a case at the function list_multi_edit()
of txp_list.php
.
françois
Offline
Pages: 1