Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2024-10-31 17:51:37

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 197
Website

How to get current URL

I have Txp that generates an HTML form:

<form method="POST" action='/tools/<txp:article_url_title />'>
[...snip...]

When I use the preview links from the admin panel, the URL is:

https://<site>/textpattern/index.php?txpreview=<number>

So, my Txp generates the wrong URL when previewed. How do I get the current URL in Txp?

Offline

#2 2024-10-31 23:46:03

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 197
Website

Re: How to get current URL

Just to answer my own question for posterity:

<form method="POST" action='<txp:page_url />'>

Offline

#3 2024-11-01 07:55:37

kuopassa
Plugin Author
From: Porvoo, Finland
Registered: 2008-12-03
Posts: 238
Website

Re: How to get current URL

You can leave out action if you intend to process the form on the URL in which the form is located. So this is fine:

<form method="POST">

Offline

#4 2024-11-01 20:30:01

skewray
Member
From: Sunny Southern California
Registered: 2013-04-25
Posts: 197
Website

Re: How to get current URL

So, it does! If there was a reason why I wrote the form that way ten years, then it’s been lost to the mists of time.

Offline

Board footer

Powered by FluxBB