2 of 2
2
Updated to 1.6…can’t find where to hide templates
Posted: 22 June 2007 01:12 PM   [ Ignore ]   [ # 19 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

Ah, well you won’t be able to do embeds, because the PHP exits the script before any subtemplates are parsed.  View your 404 page in the browser, and just cut and paste it’s rendered source HTML, so this particular template will be free of tags.

 Signature 
Profile
MSG
 
 
Posted: 22 June 2007 01:46 PM   [ Ignore ]   [ # 20 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1570
Joined  08-02-2006

I see.  It seems the result is recognizing my exp tags for recent posts, etc… (I couldn’t just copy the html source as I have a “secondary” embed which holds the dynamic information in my sidebar) but it doesn’t seem to be recognizing my stylesheet.  Is that another downfall of this?

 Signature 

Deron Sizemore
==========
Random Jabber | Sizcons | NiceStylesheet | Kentucky Golfing | LogoGala
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 22 June 2007 01:56 PM   [ Ignore ]   [ # 21 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

It’s fairly simple, Deron; I think you’re just trying to absorb too much at once.

1) You need PHP to send the 404 header
2) You need to exit ExpressionEngine or it will still try to send its own headers, which will result in errors
3) Because you are exiting ExpressionEngine during the parsing of the parent template, you must keep all content on this single template.
4) You can use any tags you like in the template, except things parsed after PHP on Output.  Without getting into the nitty gritty of parse order, that means that things like Weblog tags are fine.  Template global variables and embed tags, however, are not.

So essentially, you just need to combine your templates that you use to build your 404 page into a single template (for this page only, I’m not suggesting you have to do that for the actual 404 template), and work from there.  If it’s all too much trouble, that’s fine too; I’m just giving you options to do what you’re describing that you want to happen.

 Signature 
Profile
MSG
 
 
Posted: 22 June 2007 01:59 PM   [ Ignore ]   [ # 22 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

Actually, I just thought of another solution.  Create a template includes/exit and enable PHP parsing and add just:

<?php exit; ?>

In includes/index cut and paste your full 404 template, as is.  Then at the very very bottom, add:

{embed="includes/exit"}

That should make sure that everything you want gets parsed, including embed tags prior to this one, and that the script still exits properly.  Template global variables, though, will still not work with this, as they are parsed at the very very end.

 Signature 
Profile
MSG
 
 
Posted: 22 June 2007 02:01 PM   [ Ignore ]   [ # 23 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

Never only a single way to do things, you could also just use this PHP instead of the header() commands.  Then you can do whatever you want, ignoring parsing rules, and just let EE do its thing.

<?php
global $TMPL, $OUT;
$OUT->out_type = '404';
$TMPL->template_type = '404';
?>

 Signature 
Profile
MSG
 
 
Posted: 23 June 2007 02:16 PM   [ Ignore ]   [ # 24 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1570
Joined  08-02-2006

Hi Derek.  Thanks again for helping me out with this.  I went with your last suggestion so I could use embeds in the template (seemed easier to me).  I wanted to post my template and just make sure I’ve got it right, cause when I say I’m PHP illiterate, I seriously know no PHP.  I don’t know what you’re talking about when you talk about parsing rules, headers, and the code you gave me above, I have no idea what it means. 

But anyway, here is my “includes/index” template. 

<?php
global $TMPL, $OUT;
$OUT->out_type = '404';
$TMPL->template_type = '404';
?>

{embed
="includes/.meta" page_title="404 File Not Found - Random Jabber"}

<body id="home">

<
div id="wrapper" class="clearfix">

    <
div id="masthead" class="clearfix">
        
{embed="includes/.header"}
    
</div>

    <
div id="content" class="clearfix">
        <
div id="maincontent">
                <
h1 class="notfound">404 File Not Found!</h1>
                <
p>Sorry, but the page you're looking for could not be found.  If you believe there is a problem please <a href="{path="static/contact"}">contact me</a> and I will investigate the problem.</p>  <p>Thank you.</p>
        </div>

        <div id="secondarycontent">
            {embed="includes/.secondary"}
        </div>
    </div>

<div id="footer">
{embed="includes/.footer"}
</div>

</div>

</body>
</html>

 Signature 

Deron Sizemore
==========
Random Jabber | Sizcons | NiceStylesheet | Kentucky Golfing | LogoGala
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 23 June 2007 02:33 PM   [ Ignore ]   [ # 25 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

It looks good Deron, and I tested it on your site; it is sending the proper 404 headers.

 Signature 
Profile
MSG
 
 
Posted: 23 June 2007 04:07 PM   [ Ignore ]   [ # 26 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1570
Joined  08-02-2006

Cool, thanks!

What do you use to check the site headers?  I used http://www.seoconsultants.com/tools/headers.asp and found that when I tested http://www.randomjabber.com/blog/404-error (my 404 error template) that it does not display 404 headers.  I’ve set this template as the 404 error template in my global template preferences.  Is there something else I should do?

 Signature 

Deron Sizemore
==========
Random Jabber | Sizcons | NiceStylesheet | Kentucky Golfing | LogoGala
Twitter: Deron Sizemore | LogoGala

Profile
 
 
Posted: 23 June 2007 11:26 PM   [ Ignore ]   [ # 27 ]  
Administrator
Avatar
RankRankRankRankRankRankRank
Total Posts:  15845
Joined  06-03-2002

It’s only going to show 404 if it’s being served in response to a template that doesn’t exist.  Accessing it directly, well, it exists, so it’s not going to 404.  There are browser extensions, scripts, and addons for pretty much whatever browser you use that will let you examine headers.  Google for that for whatever browser you use; you’ll find something.

 Signature 
Profile
MSG
 
 
   
2 of 2
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 65027 Total Logged-in Users: 43
Total Topics: 82116 Total Anonymous Users: 20
Total Replies: 441313 Total Guests: 205
Total Posts: 523429    
Members ( View Memberlist )