Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-12-08 06:18:39
- mhulse
- Plugin Author
- From: Eugene Oregon
- Registered: 2005-01-21
- Posts: 200
Pass "?pg=X" into txp_article... manually?
Is it possible, or… How possible would it be to manually pass the “?pg” query string variable into <txp_article />
?
Bascially, I would like to setup a script where the article will still output an article list if someone manually changes the “?pg” GET variable to a page number that does not exist…
For example, lets say I only have two paginated pages… and someone inputs “?pg=3” into the URL… That would return nothing via the <txt_artlicle />
tag… I would want to check if the return value of <txp_article />
is “”, and then itterate to the nearest page number that returns articles.
How possible does that sound?
Lol, am I making sense here? :D
TIA!
Cheers,
Micky
Offline
Re: Pass "?pg=X" into txp_article... manually?
What are you asking? That, if $thispage['pg']
is bigger than $thispage['numPages']
, then $thispage['numPages']
will be outputted?
Because I don’t actually get what you mean, if you want make input field for changing pg
, that just create field named to pg
.
Cheers!
Offline
Re: Pass "?pg=X" into txp_article... manually?
Not tested but you could put to top of your page something like:
<txp:php>
global $thispage;
if($thispage['pg'] < $thispage['numPages']) {
$path = site_url().section().'/?pg='.$thispage['numPages'];
header("HTTP/1.x 301 Moved Permanently");
header("Status: 301");
header("Location: ".$path);
header("Connection: close");
}
</txp:php>
Remember, not tested at all.
Cheers!
Offline
#4 2007-12-08 07:04:20
- mhulse
- Plugin Author
- From: Eugene Oregon
- Registered: 2005-01-21
- Posts: 200
Re: Pass "?pg=X" into txp_article... manually?
Hi Gocom! Thanks for the reply. :)
Yah, that sounds good to me… You gave me some good ideas. Thanks for the tips.
Sorry if I did not explain well. Basically, I want to have <txp:article />
return an article list, even if the URL query string is manually changed to be a page number that does not exist… Kinda hard to explain.
I am thinking about writing a function that will check for this, and alter $_GET['pg']
by calling itself if <txp:article />
returns FALSE
. But, now that you mention $thispage['numPages']
, I may use that to error-check against.
Thanks again for the tips! Sometimes I need the pro’s to get me going in the right direction. :D
Cheers,
Micky
Offline
#5 2007-12-08 07:05:41
- mhulse
- Plugin Author
- From: Eugene Oregon
- Registered: 2005-01-21
- Posts: 200
Re: Pass "?pg=X" into txp_article... manually?
Gocom wrote:
Not tested but you could put to top of your page something like:
AHHHH! Sweeet! Thanks Gocom! That looks like a great approach. ;)
I will be dinking with that now.
You rock! :D
Cheers,
Micky
Offline