Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#97 2005-01-15 05:03:17

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

As always, Zem you are the man :)

I’m sure this is a stupid question, but I can’t find the answer.

How do you handle navigation (as in rendering hypertext lists of sections, nested categories, breadcrumb and so on) with the rewrite engine ?

Offline

#98 2005-01-15 07:28:13

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

tmac,

I’m not sure what’s going on there. Everything else looks like it works. If the subdirectory was causing a problem it would also break other kinds of links.

I just double checked, and categories with numbers in their names work fine here.

Try this in your page template, and see what it outputs on the category page:

<?php echo "category=".gps('c'); ?>


Alex

Offline

#99 2005-01-15 07:36:21

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Jeremie,

You’d need plugins to do that kind of thing.

It’s easy enough to write a plugin that works with zem_rewrite. It has two functions for generating links: zem_format_link($scheme, $text, $components), which returns a complete <a href> tag, and zem_format_url($scheme, $components), which returns just the URL.

$scheme is the name of the URL scheme (i.e. ‘article’, ‘category’, etc). $components is an array containing all the necessary parts, e.g. array(‘section’=>‘mysection’, ‘category’=>‘mycategory’). Check zem_permlink() etc for more detailed examples.


Alex

Offline

#100 2005-01-15 19:15:37

JustinLow
Plugin Author
From: Singapore
Registered: 2004-04-25
Posts: 57
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Zem, if possible, could we have a version of <txp:comments_invite /> using your plugin? :)


Justin

Offline

#101 2005-01-15 21:45:24

tmacwrig
Archived Plugin Author
Registered: 2004-03-06
Posts: 204
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

zem, I figured it out (finally!)

also, let this be a note to other people having trouble with categories: if you had been using textpattern’s usual rewrites before, with the holder files and all, you need to delete those files (the text files with no extension), or your install will still use them and it wouln’t recognize the cat name.

Offline

#102 2005-01-15 22:17:52

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

And you need to set the URL scheme to “clean”. I lost 41 minutes (I counted :p) yesterday hammering my server and the rewrites rules, before I figure that out :-/

Offline

#103 2005-01-16 14:48:13

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

I’m trying out the plugin at the moment and I want my URLs to look like this:

(1) www.domain.de/section/category/url-only-title/

or, if no category is set

(2) www.domain.de/section/url-only-title/

The first version works fine, the second one causes problems: no articles appear.

Is there a way to use this without having to give each article a category?

This is the URI scheme I use in the plugin:

<code>
$uri_scheme[‘article_urltitle’] = ‘{section}/{category}/{url_title}/’;
$uri_scheme[‘category’] = ‘{section}/{category}/’;
$uri_scheme[‘article’] = ‘{section}/{url_title}/’;
$uri_scheme[‘section’] = ‘{section}/’;
</code>

I noticed that I can get (2) to work if I swap lines 2 and 3 but then, of course, (1) doesn’t work anymore.

I should add that I use this together with the swf_if_empty plugin and my article form looks like this:

<code>
<pre>
<txp:swf_if_empty field=“category1”> <h2> <txp:zem_permlink scheme=“article”> <txp:title /> </txp:zem_permlink> </h2>
</txp:swf_if_empty>

<txp:swf_if_not_empty field=“category1”> <h2> <txp:zem_permlink scheme=“article_urltitle”> <txp:title /> </txp:zem_permlink></h2>
</txp:swf_if_not_empty>

<p><txp:excerpt /></p>
</pre></code>

Any solution to this? Thanks.

Last edited by andreas (2005-01-16 14:53:10)

Offline

#104 2005-01-16 20:40:47

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Sorry, me again.

I love this plugin, but two things are left to be cleared up.

One is the category problem (see my post immediately above this one), the other is that my search doesn’t work .

I doesn’t matter if I use the built in search input form or my own that calls its own section like so /search/index.php, I get a 404.

I even tried putting an old-style placeholder file for just this section in the root plus an addition to .htaccess. This way, I got the right page template but not results in it .

Last edited by andreas (2005-01-16 20:44:27)

Offline

#105 2005-01-17 00:34:27

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Andreas,

I use “/search/” as the input form action. Easiest way to do that is by putting this into a txp form:

<form action="/search/" method="get"><input type="text" name="q" value="" size="12" /></form>

..and use <txp:output form form="mysearchform" /> to display it.

As for categories: One way around the problem would be to add something extra to one of the two URL schemes, so that they are no longer ambiguous. For example:

$uri_scheme[‘category’] = ‘{section}/cat/{category}/’;

..or:

$uri_scheme[‘article’] = ‘{section}/article/{url_title}/’;

You could use any string in place of ‘cat’ or ‘article’, provided it doesn’t clash with anything else.


Alex

Offline

#106 2005-01-17 07:17:12

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

zem,

many thanks. I already used my own search form but it read:

<code><form action=”/search/index.php”></code> so that caused the problem. It works now. Thanks.

Is there a quick explanation why it doesn’t work with index.php?

As to the URLs, I was trying to stick with the URL scheme of my existing site which is static html and which, obviously, only uses subdirectories when they are needed. If I add a string I might as well give the articles a category — I just tried to keep the URLs as short as possible.

So I take it there’s no way I can have both categorised and uncategorised articles with your plugin?

Last edited by andreas (2005-01-17 07:19:45)

Offline

#107 2005-01-17 07:25:54

andreas
Member
Registered: 2004-02-28
Posts: 453
Website

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

Oh, I just realised that the links in the search results page do not use the zem_permlink structure and therefore don’t work. I set up a search results form like Dean suggested but there seems to be no way of getting the zem_permlink tags working in it.

Sorry for asking all these questions but I’m redesigning my existing site which has quite a few quite different sections and I try to replicate the URLs as closely as possible to make it easier to redirect people once the TXP site is up. That’s why I have such specific issues.

Thanks for all the help!

Offline

#108 2005-01-17 07:38:25

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: [plugin] [ORPHAN] zem_rewrite: configurable clean URLs

> Is there a quick explanation why it doesn’t work with index.php?

zem_rewrite just matches URLs against known patterns. ‘index.php’ doesn’t match.

> So I take it there’s no way I can have both categorised and uncategorised articles with your plugin?

Sure you can. Something like this should work:

<code>
$uri_scheme[‘article’] = ‘{section}/{category}/{article}/{title}’;
$uri_scheme[‘article_nocat’] = ‘{section}/{article}/{title}’;
$uri_scheme[‘article_alt’] = ‘{section}/{article}/’;
$uri_scheme[‘category’] = ‘{section}/{category}/’;
$uri_scheme[‘section’] = ‘{section}/’;
</code>

Or:

<code>
$uri_scheme[‘article’] = ‘{section}/{category}/{url_title}’;
$uri_scheme[‘article_nocat’] = ‘{section}/{url_title}’;
$uri_scheme[‘article_alt’] = ‘{section}/{article}/’;
$uri_scheme[‘section’] = ‘{section}/’;
</code>

Where you’ll run into problems is if you expect both ‘{section}/{url_title}’ and ‘{section}/{category}’ to work, because zem_rewrite can’t tell them apart.


Alex

Offline

Board footer

Powered by FluxBB