Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2011-07-07 13:47:17
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
URL-only title
I am hoping someone can assit me with my most recent hurdle with a project I am working on. I am transitioning a client from a custom CMS (that uses ASP) to to Textpattern. There are over 1500 articles. So far, I have been succesful in getting all of the relevant data to import into Textpattern. The issues that we have come across so far we have been able to overcome and I feel comfortable where we stand on that front. I have generously used glz_custom_fields to store all the data.
Now the problem. At some point I will need to redirect the old urls to the new articles.
The Custom CMS uses multiple “sub sections” to create the url path to the article (example: http://forum.textpattern.com/design/furniture/women/colors/dark/black.aspx) In the custom CMS everytime a folder was created it acted like a sub section on the url path.
What I planned to do is use the URL-only title field, strip off the .aspx so that the field contained “design/furniture/women/colors/dark/black” Then in the htaccess file I can direct all aspx pages to the php pages.
My problem is that Textpattern does not like “/” in that field. It converts all the “/” to “%2F” — this occurs even though when I look at the mySQL DB it shows me the “/”
I have looked at gbp_permanent_links but I do not beleive that is the solution.
If anyone has attempted such a task or has any suggestions how I may be able to accomplish this even if (cover your ears) I need to modify something in the core so that the slashes are not converted — I am willing to listen —
Thanks.
progre55
Offline
Re: URL-only title
See this forum entry.
Last edited by jayrope (2011-07-07 13:53:18)
A hole turned upside down is a dome, when there’s also gravity.
Offline
#3 2011-07-07 14:00:06
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: URL-only title
jayrope:
THANK YOU. This seems to be exactly what I am looking for to complete the taask. I will not be able to test for a little bit, but I will definitely be putting this into the structure and I will let you know — thanks again for the response.
progre55
Offline
#4 2011-07-07 14:15:17
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: URL-only title
jayrope:
So I am sure that I am doing this correctly.
1. Create a field called redirect.
2. In the redirect field put the old url which in my example would be http://forum.textpattern.com/design/furniture/women/colors/dark/black
3. Create a form <txp:output_form form="redirect" />
4. Place the below code in the form.
<txp:if_individual_article><txp:if_custom_field name="redirect">
<txp:php>
global $thisarticle;
Header("HTTP/1.1 301 Moved Permanently");
Header('Location: '.$thisarticle['redirect'].'');
</txp:php>
</txp:if_custom_field></txp:if_individual_article>
Then if I understand correctly, when someone tries to hit http://forum.textpattern.com/design/furniture/women/colors/dark/black they would be redirected to http://forum.textpattern.com/black — which would be the new name of the textpattern article.
If I am correct about the above, where does the <txp:output_form form="redirect" />
go — in the body or header section?
progre55
Last edited by progre55 (2011-07-07 15:52:40)
Offline
Re: URL-only title
If I am correct about the above, where does the <txp:output_form form=“redirect” /> go — in the body or header section?
The higher the faster. But you can even put it inside your article form which is useful if you use different article forms.
I am using this powerful 301 redirect in some article bodies.
Last edited by merz1 (2011-07-07 19:57:57)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#6 2011-07-07 19:55:42
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: URL-only title
merz1
Thanks for the feedback. Question, I am assuming the above method does not require that an actual article with the “old” url be created in Textpattern for this to work. Since I am moving the client from a custom CMS, I only have the “new” articles in Textpattern. But I do have all the old articles in a custom field.
progre55
Offline
Re: URL-only title
Sorry, I was only answering your question … edited my answer to make that clearer.
I am assuming the above method does not require that an actual article with the “old” url be created in Textpattern for this to work.
I didn’t dive too deep … but yes the redirect needs an initial call to the original ‘old’ URL (which pretty much kills that solution (and my answer)).
Sorry, no help for tonight (but I am subscribed) so maybe more ‘helpful’ answers tomorrow.
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Re: URL-only title
Excuse me, I am tired, but maybe this can be a help:
What I planned to do is use the URL-only title field
What is the URL-only title field … Which txp:tag to call it?
You can try to switch off HTML escaping by using escape=""
(“html” is default).
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
#9 2011-07-08 02:02:36
- progre55
- Member
- Registered: 2006-05-02
- Posts: 668
Re: URL-only title
jayrope/merz1:
I was able to get this to work (for anyone who may need such a function):
<txp:if_individual_article>
<txp:if_custom_field name="redirect">
<txp:php>
txp_status_header('301 Moved Permanently');
header('Location: '.$thisarticle['redirect'].'');
exit;
</txp:php>
</txp:if_custom_field>
</txp:if_individual_article>
This script looks at an existing article and redirects it to the url that is in the custom field named ‘redirect.’ Unfortunately, what I have realized is that this will not solve my problem.
What I need is increased flexability so that I can define the exact url of articles. The existing url format is:
http://www.example.com/travel/united_states/texas/hotels_intro.aspx
I need to be able to create Textpattern articles that have the same url structure
http://www.example.com/travel/united_states/texas/hotels_intro (minus the .aspx)
I can then strip off the .aspx using htaccess and get the articles to function properly.
I already have the old path in a custom filed so my ideal solution would be to tell Textpattern to use xyz custom field instead of URL-only title —-
I am willing to try everything. At one point I thought this gbp_permanent_links was my answer. But either I do not know how to use it (which is quite possible) or it cannnot do what I want it to do —-
Again, any help or guidance would be appreciated.
progre55
Last edited by progre55 (2011-07-08 02:04:30)
Offline
Re: URL-only title
I don’t see a way to use a slash separated path in Textpattern.
You have to find a clean .htaccess way to redirect from slash/paths to hyphen-paths and strip the ‘.aspx’.
You have to solve the call to the old URL on the web server and not inside Textpattern.
A solution can be via .htaccess or a PHP wrapper around the Textpattern index.php.
RewriteRule !\.(aspx)$ - [S=n]
# If no .aspx request then skip next n instructions
# Rewrite slashes to hyphens code goes here
# Directory slashes need some special treatment for domain and section calls though.
RewriteRule ^(.*)\.aspx$ $1 [R=301,L]
- To get an idea: Rewrite underscores to hyphens
- Helpful: Mod_Rewrite Variables Cheatsheet
Last edited by merz1 (2011-07-08 12:51:42)
Get all online mentions of Textpattern via OPML subscription: TXP Info Sources: Textpattern RSS feeds as dynamic OPML
Offline
Pages: 1