Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-08-10 18:28:34

Bongo-man
Member
Registered: 2009-03-18
Posts: 243

[SOLVED] HowTo remove a same string from many URLs (saving time)

I need to remove a same string from many article-URLs (permalinks), but I’m not skilled about SQL.

I’m talking of the final part of many files. During some years I’ve named all the files in a way they looked like static files; so I wrote ‘.html’ at the end of each article-URL -> ‘filename.html’ .

I must point out that the article-titles, in my website, don’t match the permalinks.

So I want remove the ‘.html’ string from the final portion of all the permalinks.

In a manual way I think I would spend all he night.

So I wonder about a shorter way to do the same thing…

(My website profits a MySQL database with phpmyadmin).
TNX

Last edited by Bongo-man (2018-08-10 21:18:18)

Offline

#2 2018-08-10 19:05:51

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: [SOLVED] HowTo remove a same string from many URLs (saving time)

This is untested but I think it should work (take a full backup first):

UPDATE textpattern SET url_title = TRIM(TRAILING ".html" FROM url_title);

Offline

#3 2018-08-10 19:26:05

Bongo-man
Member
Registered: 2009-03-18
Posts: 243

Re: [SOLVED] HowTo remove a same string from many URLs (saving time)

Thanks for your answer.
I’ve tried your query by phpmyadmin and the answer has been:

“ #1146 – Table ‘Sql229117_1.textpattern’ doesn’t exist”

Afterwards I’ve posted the same expression inside the table ‘_1textpattern’.
There was already this expression:
SELECT * FROM `_1textpattern` WHERE 1

So I’ve posted bellow it; then I ‘ve pushed the btton

and the answer was: “#1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘UPDATE textpattern SET url_title = TRIM’ at line 2”.

Last edited by Bongo-man (2018-08-10 19:49:25)

Offline

#4 2018-08-10 21:16:06

Bongo-man
Member
Registered: 2009-03-18
Posts: 243

Re: [SOLVED] HowTo remove a same string from many URLs (saving time)

Thanks.

Althought I don’t know SQL at all, after a quick MySQL self-apprentiship I’ve corrected a little your expression and saved some hours.

That’s the solution: ‘ ‘, instead of “ “ and “.1textpattern” is the database I’m using for the textpattern installation.

So, it becames:

UPDATE .1textpattern SET url_title = TRIM (TRAILING ‘.html’ FROM url_title);

Last edited by Bongo-man (2018-08-10 21:16:48)

Offline

Board footer

Powered by FluxBB