Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Title Help
Hey :)
Please take a look at the following code:
<txp:adi_gps />
<txp:site_name /><txp:if_section name="default"> - <txp:site_slogan /><txp:else /> - <txp:section title="1" /></txp:if_section><txp:if_category> - <txp:category title="1" /></txp:if_category><txp:if_variable name="month"> – Issue # <txp:php>echo date("F Y",strtotime($_GET["month"]));</txp:php></txp:if_variable><txp:if_individual_article><txp:if_section name="articles"> - Issue # <txp:posted format="%B %Y" /></txp:if_section> : <txp:title /></txp:if_individual_article><txp:if_search> : <txp:page_url type="q" /></txp:if_search><txp:if_status status="404"> - Error : 404 File not found!</txp:if_status><txp:if_status status="403"> - Error : 403 Forbidden</txp:if_status>
My problem is that when I have an error 404 or 403 it will show my site slogan in the title, I don’t want it to! I only want the site slogan to show when on the default section, any ideas of how to solve this? Thanks
Last edited by driz (2009-03-15 21:55:52)
~ Cameron
Offline
#2 2009-03-15 21:56:52
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Title Help
You need to edit page template error_default (or error_404, error_403, if you created those).
Offline
Re: Title Help
<txp:if_section name="default"> - <txp:site_slogan />
<txp:else /> - <txp:section title="1" /></txp:if_section>
Error documents aren’t necessarily in section ‘default’ so your else branch is probably being executed.
I think 404/403 pages are actually sectionless (i.e. section set to NULL) as I found out recently and posted about on the forum (somewhere!) which is a trifle annoying in some cases. But you can try either:
- An extra
<txp:if_status>
in a form that handles your<head>
to display something different, kinda like you are doing already - Put the markup in your error_default page
- Use a custom page template called error_404 (or error_403) to handle the situations differently
EDIT: And Els beat me to it… :-)
Last edited by Bloke (2009-03-15 22:01:23)
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
Re: Title Help
I use custom error_404 and error_403 pages already, but the Title is in a form called header. How would I do the extra if_status idea you had? I’d need something that basically said allow the bunch of code in the first place to ONLY run if a status error hasn’t occurred.
<txp:adi_gps />
<txp:if_status status="">
<txp:site_name /><txp:if_section name="default"> - <txp:site_slogan /><txp:else /> - <txp:section title="1" /></txp:if_section><txp:if_category> - <txp:category title="1" /></txp:if_category><txp:if_variable name="month"> – Issue # <txp:php>echo date("F Y",strtotime($_GET["month"]));</txp:php></txp:if_variable><txp:if_individual_article><txp:if_section name="articles"> - Issue # <txp:posted format="%B %Y" /></txp:if_section> : <txp:title /></txp:if_individual_article><txp:if_search> : <txp:page_url type="q" /></txp:if_search>
</txp:if_status>
<txp:if_status status=“404”><txp:site_name /> – Error : 404 File not found!</txp:if_status>
<txp:if_status status=“403”><txp:site_name /> – Error : 403 Forbidden</txp:if_status>
Last edited by driz (2009-03-15 22:10:16)
~ Cameron
Offline
#5 2009-03-15 22:09:54
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Title Help
driz wrote:
but the Title is in a form called header.
You don’t have to use that form on your error pages, do you? Seems easier to me to just put this in your <title>
tags on the error page:
<txp:site_name /> - <txp:site_slogan /> - Error : 404 File not found!
Offline
Re: Title Help
Well my solution was this:
<txp:adi_gps />
<txp:if_status status="200">
<txp:site_name /><txp:if_section name="default"> - <txp:site_slogan /><txp:else /> - <txp:section title="1" /></txp:if_section><txp:if_category> - <txp:category title="1" /></txp:if_category><txp:if_variable name="month"> – Issue # <txp:php>echo date("F Y",strtotime($_GET["month"]));</txp:php></txp:if_variable><txp:if_individual_article><txp:if_section name="articles"> - Issue # <txp:posted format="%B %Y" /></txp:if_section> : <txp:title /></txp:if_individual_article><txp:if_search> : <txp:page_url type="q" /></txp:if_search></txp:if_status><txp:if_status status="404"><txp:site_name /> - Error : 404 File not found!</txp:if_status><txp:if_status status="403"><txp:site_name /> - Error : 403 Forbidden</txp:if_status>
Any ideas to improve it, or would you say this is the best way of dealing with it?
Last edited by driz (2009-03-15 22:12:41)
~ Cameron
Offline
#7 2009-03-15 22:17:48
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Title Help
driz wrote:
or would you say this is the best way of dealing with it?
No I wouldn’t ;) But if that’s how you want to do it, do it. (The code after <txp:else />
will never be executed though…)
Offline
Re: Title Help
What do you mean? The code after <txp:else />
IS executed though! :S
If you look at the site http://paperview.org/ you will see that ALL of that code is executed as it should, so what is that wouldn’t be executed after the <txp:else />
Last edited by driz (2009-03-15 22:24:03)
~ Cameron
Offline
#9 2009-03-15 22:26:18
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Title Help
Doh! I overlooked <txp:if_section name="default">
… so I thought it was <txp:if_status status="200">...<txp:else />
. Sorry!
Offline
Re: Title Help
Cool man, no problem, just wanted to double check it had no bugs or ought.
Thanks for your help everyone. ;)
~ Cameron
Offline
Pages: 1