Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [archived] gbp_faux_static - uri forwarding.
I’ve just update the plugin to v0.6.2.
- As all the data is stored in the txp_prefs table data was limited to a certain lenght. This is now fixed.
- I’ve also added a new textpattern tag, see the plugin help page for more detail.
Offline
#14 2005-09-13 09:51:32
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: [archived] gbp_faux_static - uri forwarding.
Hey Graeme,
just a few questions, as I’m not smart enough to work it out from the source code & help docs :-/
- what should the permanent link mode be set to under admin > prefs > site prefs?
- how can we make the
txp:permlink
tag use these urls? is there an equivalent oftxp:sgb_url_handler_permlink
? - would it be possible to provide a few more regexp examples? While I kinda understand the one you’ve got, I’m not sure if I understand it enough to extrapolate ;-)
- does this plugin produce error pages (404 et al) for failed matches? If not do you have any plans for an
sgb_error_documents
equivalent? - what does “allow category forwarding” do (plugin prefs)?
My aim is to make the faux static urls /section/category/title
for 3 sections and /section/date/title
for one section of the site I’m building. I’m really interested in this plugin as ole’ sgb seems to have moved on, and this seems like it should be able to replace it.
Thanks in advance!
peace – boblet
Offline
Re: [archived] gbp_faux_static - uri forwarding.
I’m afraid I don’t understand how to use this.
What would I do if I want an URL scheme like /section/category/title
?
Thanks for any hints.
Offline
Re: [archived] gbp_faux_static - uri forwarding.
boblet wrote:
what should the permanent link mode be set to under admin > prefs > site prefs?
You can have textpattern set to use any of the permlink link modes, gbp_faux_static works ‘up top’ of textpattern’s own URL analysis.
how can we make the
txp:permlink
tag use these urls? is there an equivalent oftxp:sgb_url_handler_permlink
?
I’ve been working on this and in v0.6.3 I added the initial support for <txp:gbp_faux_permlink />
. Within the plugin preferences there is now a ‘Default Permanent Link Format’ field and this can even be overridden in the add/edit tab on a rule by rule basis.
The permanent link format might look similar to a regexp forwarder rule, but in fact it isn’t a regexp. The format uses the same meta patterns as a regexp rule, such as:
/(?#section)/(?#category)/(?#title)
would it be possible to provide a few more regexp examples? While I kinda understand the one you’ve got, I’m not sure if I understand it enough to extrapolate ;-)
I’ve been busy recently. But sure, I will write some better documentation soon. Starting with what you set out in your aim below. ;)
does this plugin produce error pages (404 et al) for failed matches? If not do you have any plans for an
sgb_error_documents
equivalent?
After textpattern’s own URL analysis gbp_faux_static will produce an 404 error if no matches are found. The 404 this then handled in the same way as other 404s returned by textpattern.
I’m planning to add additional forwarding support, so it will be possible to forward uri to different http status codes, such as “301 : Moved Permanently”
what does “allow category forwarding” do (plugin prefs)?
If enabled you will see a category popup in the add/edit tab. Why did I add this as an option? Well if you forward to a category only you will get a 404 error. To prevent this you need to also forward to a section or article. This is due to the inner workings of textpattern.
My aim is to make the faux static urls
/section/category/title
for 3 sections and/section/date/title
for one section of the site I’m building. I’m really interested in this plugin as ole’ sgb seems to have moved on, and this seems like it should be able to replace it.
Okay… here are the steps you need to follow to get the urls you want:
- Make sure you’ve got at least version 0.6.3 installed
- Enable ‘Allow Custom Permanent Links’ in the plugin preferences.
- Add this regexp rule:
%^\/(?#section name!=foo)\/(?#category)\/(?#title)$%
(Note. foo is the 4th unique section) - As we’re using meta patterns you leave all the popups empty.
- In ‘Permanent Link Format’ field add
/(?#section)/(?#category)/(?#title)
. - Add a second regexp rule:
%^\/(?#section name=foo)\/(?#date)\/(?#title)$%
- Again as we’re using meta patterns you should leave all the popups empty.
- In ‘Permanent Link Format’ field add
/(?#section)/(?#date)/(?#title)
. - And finally in your article forms use
<txp:gbp_faux_permlink />
or<txp:gbp_faux_permlink> ... </txp:gbp_faux_permlink>
wherever you need a permanent link.
I hope this helps.
Offline
Re: [archived] gbp_faux_static - uri forwarding.
andreas wrote:
I’m afraid I don’t understand how to use this.
What would I do if I want an URL scheme like/section/category/title
?
Andreas, you should be able to follow the steps I laid out in my last post.
Offline
#18 2005-09-14 09:01:14
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: [archived] gbp_faux_static - uri forwarding.
Wow Graeme, that’s an impressively detailed reply! Thanks so much for taking the time to explain everything so clearly. Having some more examples makes things a lot clearer.
However, some problems ;-)
Although I can hard-code clean links with the corresponding static page specified and they’ll work fine, it seems that any txp-generated links will use the txp-specified permanent link mode, including gbp_faux_article
. I’d like all links to be the clean format we’ve defined via static patterns. For example I’d like to make a list of recent articles <txp:if_article_list><ul><txp:gbp_faux_article limit="10" sortby="Posted" sortdir="desc" listform="dev-recent-articles" /></ul></txp:if_article_list>
, with dev-recent-articles being <li><txp:gbp_faux_permlink><txp:title /></txp:gbp_faux_permlink></li>
. Using this code gives me links based on messy urls or whatever the txp pref is set to, not the hoped-for static pattern defined for that section.
Are there equivalents or workarounds for other txp url tags? specifically @txp:link_to_home@, txp:article_custom
, txp:older
and txp:newer
? It seems like improving url handling requires a lot of modification huh :-)
Also, I get the following error if I put anything into static > preferences > Default Permanent Link Format:
Fatal error: Cannot redeclare gbp_faux_permlink_replace() (previously declared in /path/to/textpattern/lib/txplib_misc.php(429) : eval()'d code:966) in /path/to/textpattern/lib/txplib_misc.php(429) : eval()'d code on line 966
It’s probably just me doing something wrong though.
thanks again!
peace – boblet
Last edited by boblet (2005-09-14 11:27:23)
Offline
Re: [archived] gbp_faux_static - uri forwarding.
boblet wrote:
Wow Graeme, that’s an impressively detailed reply! Thanks so much for taking the time to explain everything so clearly. Having some more examples makes things a lot clearer.
Great! – I’m glad the time was worth it. :-)
However, some problems ;-)
I was able to reproduce the problems you were having and have attempted to fix them. I’ve updated the 0.6.3 release if you download, reinstall and enter a ‘Permanent Link Format’ that the problems with <txp:gbp_faux_permlink />
should go away.
Are there equivalents or workarounds for other txp url tags? specifically
txp:link_to_home
,txp:older
andtxp:newer
? It seems like improving url handling requires a lot of modification huh :-)
Good question, I should look at those tags.
It’s probably just me doing something wrong though.
No it was my fault – sorry!
Offline
#20 2005-09-14 11:49:21
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: [archived] gbp_faux_static - uri forwarding.
hah – was just in the process of editing my post, and you bet me to it. Again, thank you! I’ll have a play with the next one and let you know how I get on.
btw I’ve used a hard link to href=”/” instead of txp:link_to_home
, but an equivalent of txp:article_custom
would be great!
peace – boblet
PS to elaborate a little, I’m presently building around this (theoretical) section structure; default for my main language, index.en for English default equivalent, then 3 sections each eg about (article page-can use if_category
or if_custom_field
to provide localised formatting), about.ja & about.en (section article list pages, one per language). I plan to have a link at the top of each page to change to the same content in the other language. for default/index.en and for ‘section article list pages’ the link can be hard-coded. For the article sections I’m thinking to use txp:newer/older and make sure I always post the same language first. kludgy but I can’t think of a better way to do this without becoming a PHP wiz overnight and whipping up some kinda Apache multiviews plugin
Offline
Re: [archived] gbp_faux_static - uri forwarding.
boblet wrote:
an equivalent oftxp:article_custom
would be great!
That should be easily done, I’ll try get it in for the next revision.
PS to elaborate a little, I’m presently building around this (theoretical) section structure; default for my main language, index.en for English default equivalent, then 3 sections each eg about (article page-can use
if_category
orif_custom_field
to provide localised formatting), about.ja & about.en (section article list pages, one per language). I plan to have a link at the top of each page to change to the same content in the other language. for default/index.en and for ‘section article list pages’ the link can be hard-coded. For the article sections I’m thinking to use txp:newer/older and make sure I always post the same language first. kludgy but I can’t think of a better way to do this without becoming a PHP wiz overnight and whipping up some kinda Apache multiviews plugin
Hmm… sounds cool. I’m actually in the process of developing another plugin gbp_l10n. it will provide a way of localising articles, section/category titles and links etc… It’s not ready to be released publicly but it might interest you and I could do with someone willing to test :-)
Send me a private message and I’ll try and sort something out.
Offline
#22 2005-09-14 15:30:42
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: [archived] gbp_faux_static - uri forwarding.
:me does the underwear dance of joy
It’s working! I put /(?#section)/(?#category)/(?#title)
in static pages > prefs > default perm link format and all the links have magically become section/category/title. This works even for txp:article_custom
!
There’s a couple of things I need to play with further: this default seems to override /(?#section)/(?#date)/(?#title)
for the log section. Also, if I don’t specify a section in the pulldown for the date pattern (recommended in step 7 of Graeme’s post #16 above), it’ll say “saved” but won’t be listed. Finally I haven’t tested support for other default url-based tags, but yeah! Great stuff!!
Thanks Graeme, and hope the next few weeks go well for ya ;-)
peace – boblet
Offline
#23 2005-09-14 19:34:45
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: [archived] gbp_faux_static - uri forwarding.
Despite your elaborate explanations, Graeme, I’m afraid I still don’t understand everything :(
I want to change from /section/title to /category/title, this only for one particular section. I got this working:
URI: %^\/(?#category)\/(?#title)$%
Permanent Link Format: /(?#category)/(?#title)
using <txp:gbp_faux_permlink />
in the article form.
Now I would like requests for /section/title to be forwarded to /category/title. What I thought I had to do was this:
URI: %^\/(?#section name=artikel)\/(?#title)$%
Permanent Link Format: /(?#category)/(?#title)
(‘artikel’ being the name of this particular section). But I must be wrong since it’s not forwarding to /category/title.
Another question:
My articles can have two categories assigned. The above pattern only uses category1. I don’t suppose it’s possible that, if on a category page that is category2 of an article, it will use category2 in the permlink?
Offline
#24 2005-09-14 19:48:03
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: [archived] gbp_faux_static - uri forwarding.
I also just noticed that, when the url is /category/title, <txp:page_title />
no longer displays the article title (as it does with /section/title), but it does display the category. But that’s a problem outside of the plugin I suppose…
Last edited by doggiez (2005-09-14 19:49:52)
Offline