Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2011-12-12 15:05:00
- RipvanFish
- Member
- Registered: 2009-07-09
- Posts: 35
Clean URL's and conditional Tags
Hi,
I just activated clean URL’s in TXP’s settings and it works fine, expect for conditional tags.
<txp:if_section name="section_name">, <txp:if_article_id id="n">
just dont fire.
A plugin I made myself (that depends on passed ID in the url) is not working either.
When i try to var_dump($_GET) I’m getting an empty array.
I am pretty sure that has something todo with my .htaccess file, so here is what i have:
#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /relative/web/path/
# Force Apache to use WWW
RewriteCond %{HTTP_HOST} ^mydomain.com$ [NC]
RewriteRule ^(.*) http://www.mydomain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
#add trailing slash
RewriteRule ^(.+[^/])$ http://www.mydomain.com/$1/ [R=301,L]
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
thanks for your help!
regards,
fish
Last edited by RipvanFish (2011-12-12 15:06:09)
Offline
Re: Clean URL's and conditional Tags
Hi
if you activated clean url txp:if_article_id and if_section should work! i use them everyday without a problem.
For your plugin getting variable thrue GET, i think when clean url is activated the id is no longuer passed as url variable then you can get id, but i think there is a global txp value (using global) that let you get the id without GET!
Cheers
Offline
#3 2011-12-12 15:36:38
- RipvanFish
- Member
- Registered: 2009-07-09
- Posts: 35
Re: Clean URL's and conditional Tags
About the ID-Thing: it works, that’s my fault, sorry.
But let’s have a look at if_section, this is what i have in my template:
If section is “Impressum” the active class should be added to the list-item.
Accessing my page with www.domain.com/Impressum it wont get the class, accessing it with messy urls the class is set (www.domain.com/index.php?s=Impressum).
What am i doing wrong?
<li <txp:if_section name="Impressum">class="active"</txp:if_section> ><txp:section name="Impressum" link="1" title="1" /></li>
Offline
#4 2011-12-12 16:17:30
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Clean URL's and conditional Tags
Try changing the section name into all lowercase (in your tag and in Presentation > Sections). Capitals in section and category names can cause problems.
Offline
Re: Clean URL's and conditional Tags
hi
That should work! go to admin/pref and make the site on debugging mode and then go to www.domain.com/Impressum, there look at the source page (under firefox make ctrl+u) at the end of the source you will see all the queries made by textpattern and you can see where things goes wrong
Cheers
Offline
#6 2011-12-12 16:30:38
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,477
Re: Clean URL's and conditional Tags
For what you need RewriteRule ^(.+[^/])$ http://www.mydomain.com/$1/ [R=301,L]
?
Offline
#7 2011-12-14 12:57:33
- RipvanFish
- Member
- Registered: 2009-07-09
- Posts: 35
Re: Clean URL's and conditional Tags
Els schrieb:
Try changing the section name into all lowercase (in your tag and in Presentation > Sections). Capitals in section and category names can cause problems.
Thank you (again again) Els, this seem to work for me!
All i have to figure out now is, how to get (inside my plugin) the ID of the currently displayed article.
Before I where using clean URL’s i just got the ID by using $_GET inside my php code. Is there a way to get id (or section and category) inside a plugin?
Offline
Re: Clean URL's and conditional Tags
RipvanFish wrote:
Is there a way to get id (or section and category) inside a plugin?
Try:
global $thisarticle;
dmp($thisarticle);
That’ll show you everything about the current article, but it only shows up in individual article context.
There’s also a global $pretext
which contains things like the currently selected /category
and /section
. That one’s available on every page (uhhh, well, maybe not completely set on error pages) and is useful for checking things on list / landing pages.
btw, for getting stuff from the URL, check out Txp’s gps('some-var')
(to read values from $_GET
or $_POST
) and ps('some-var')
if you know the value is only coming from a $_POST
request.
Hope that helps.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#9 2011-12-14 13:56:38
- RipvanFish
- Member
- Registered: 2009-07-09
- Posts: 35
Re: Clean URL's and conditional Tags
Bloke schrieb:
RipvanFish wrote:
Is there a way to get id (or section and category) inside a plugin?
Try:
global $thisarticle;
dmp($thisarticle);
That’ll show you everything about the current article, but it only shows up in individual article context.
There’s also a global $pretext
which contains things like the currently selected /category
and /section
. That one’s available on every page (uhhh, well, maybe not completely set on error pages) and is useful for checking things on list / landing pages.
btw, for getting stuff from the URL, check out Txp’s gps('some-var')
(to read values from $_GET
or $_POST
) and ps('some-var')
if you know the value is only coming from a $_POST
request.
Hope that helps.
Thank you for your help! This will be helpful for other projects too.
Right now I made my plugin work using zem_rewrite, after installing and activating it the $_GET
var seems to get passed.
Thank you all for your help!
Offline
Pages: 1