Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

  1. Index
  2. » Archives
  3. » 404 Support

#49 2005-10-30 21:13:58

larf
Archived Plugin Author
Registered: 2005-01-31
Posts: 159
Website

Re: 404 Support

OK this is helpful, but I still have some questions. I’ve updated to the latest svn release.

This (method 1) seems to work:
<code>
register_callback(‘vdh_urltest’,‘pretext’);
function vdh_urltest() {
if (url contains something) $_GET[‘s’] = ‘article’;
}
</code>

When using this (method 2), css links are incomplete:
<code>
register_callback(‘vdh_urltest’,‘textpattern’);
function vdh_urltest() {
if (url contains something) {
global $pretext;
$pretext[‘status’] = ‘200’;
$pretext[‘page’] = ‘archive’;
$pretext[‘s’] = ‘article’;
}
}
</code>

CSS links are missing the section part at the end:
http://www.domain.net/subdir/textpattern/css.php?s=

But all in all, I still have not found the ideal method how to tell textpattern when to throw out 404s and when not.

Let’s say my plugin lives in the section ‘test’. I want 404s for all of my sections, including front page (default). Only section test should not throw out any 404s, because my plugin grabs parts of the url and does stuff with it.

I guess I should pick method 1 in this case. Anyone against?

Furthermore, does anyone here have a hot hint how to find out which section I’m in using method 1?

Offline

#50 2005-10-30 23:46:58

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: 404 Support

Thanks Sencer, that really helps. :)

Offline

#51 2005-10-31 00:29:19

domfucssion
Plugin Author
Registered: 2004-10-23
Posts: 39

Re: 404 Support

yeah!, cheers Sencer – that helps me too.

Offline

#52 2005-10-31 05:35:24

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: 404 Support

In method 1, you can do this (seems to work ok for me):

register_callback('abc_yourplugin','pretext');

and then from within your plugin function…

   // get path values, remove leading/trailing empty vals, & reset keys
    $path = array_values(array_filter(explode('/', $_SERVER['REQUEST_URI'])));
    if (!empty($path))
        $_POST['s'] = $path[0];

Seems to work ok for me, although there may be holes…

Offline

#53 2005-10-31 10:31:53

larf
Archived Plugin Author
Registered: 2005-01-31
Posts: 159
Website

Re: 404 Support

Thanks Andrew, but this method does not work if textpattern lives in a subdir. Plus, it won’t work if you visit the default section (e.g. www.domain.com or www.domain.com/subdir). But I will think of a solution as soon as I have more time…

Offline

#54 2005-10-31 11:04:28

larf
Archived Plugin Author
Registered: 2005-01-31
Posts: 159
Website

Re: 404 Support

OK, here is my solution for the problem. It requires the user to specify the section of the plugin. It seems to work in all possible scenarios and does not disable 404s for the entire site, but only for the section of the plugin.

<pre><code>
global $vdh_urltest_section;
$vdh_urltest_section = ‘article’;

register_callback(‘vdh_urltest’,‘pretext’);

function vdh_urltest() { global $vdh_urltest_section; $path = str_ireplace(rhu, ‘’, $_SERVER[‘REQUEST_URI’]); $path = array_values(array_filter(explode(‘/’, $path))); if (!empty($path) and $path0 == $vdh_urltest_section) $_POST[‘s’] = $path0;
}
</code></pre>

Any chance of getting rid of the need to specify the plugin section?

Last edited by larf (2005-10-31 11:09:15)

Offline

#55 2005-11-08 05:43:29

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: 404 Support

I’m working on a date-based archive plugin. Currently, I’m using a mini copy of pretext(), but again, this means we have to setup a tab and preference and have the user enable the plugin for the section(s) they want to use it.

Here is what I have thus far, just dealing with this part so you can see what I mean. At the moment I’ve hard-coded it so I can get on with developing the rest of the plugin itself. If I have to use a preference, then I don’t have much choice, but that really makes me want to avoid doing any more plugins of this kind.

Offline

#56 2006-06-22 15:01:21

TheEric
Plugin Author
From: Colorado & Montana.
Registered: 2004-09-17
Posts: 603
Website

Re: 404 Support

I just came across this thread.

So nice! I can get rid of the htaccess hack that was previously required for my upcoming plugin.

Last edited by TheEric (2006-06-22 15:02:21)

Offline

  1. Index
  2. » Archives
  3. » 404 Support

Board footer

Powered by FluxBB