Custom 404 inside the content area

This forum is for reporting bugs in Joomla!. Please don't report problems with extensions in here.
Forum rules
Forum Rules
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Custom 404 inside the content area

Postby Jick » Wed Jan 09, 2008 4:08 pm

Is it possible to render 404 in the content area of the site where normally the not found article would render?

Right now there is the error.php in the templates/system dir which can be customized by putting a copy in your own template dir but this file doesn't allow module calls etc.

I have no problem with a separate error file but I would like to recreate the template there with menu's and search so when someone types a wrong url and gets a 404 he or she can just keep on browsing the site or use the search function.

It would be even more easy to get a customizable error message via component so there is no need to recreate the template in error.php.

Anyone ideas?

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Thu Jan 10, 2008 12:57 pm

Am I the only one interested in accessible, useful and user friendly 404 pages?

Here's some real creative 404 examples but whats more important, most of them have "inline" pages where navigation is still in place so people can just go on browsing your site.
http://www.smashingmagazine.com/2007/08/17/404-error-pages-reloaded/?

To one of the devs, would it be possible to at least make module rendering in error.php working like in the template index.php?

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

User avatar
mcsmom
Joomla! Exemplar
Joomla! Exemplar
Posts: 7985
Joined: Thu Aug 18, 2005 8:43 pm
Location: New York
Contact:

Re: Custom 404 inside the content area

Postby mcsmom » Thu Jan 10, 2008 4:15 pm

Jick,

Of course not. I'm sure if you provide a patch it will be looked at or at least used by a lot of people.

I agree strongly with you but if you read the threads on this topic that have gone on for months, there is real disagreement here.

J! is supposed to be designed to make it easy to put up a great looking site, and this is one area where it is not great looking and also exttremely challenging to make great looking since you have to more or less hand type the template.
So we must fix our vision not merely on the negative expulsion of war, but upon the positive affirmation of peace. MLK 1964.
http://officialjoomlabook.com Get it at http://www.joomla.org/joomla-press-official-books.html Buy a book, support Joomla!.

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Fri Jan 11, 2008 10:27 am

Arno -

Why would the developers build another content management environment when we can just use normal Joomla! functionality?
To one of the devs, would it be possible to at least make module rendering in error.php working like in the template index.php?


This is even more confusing:
"Am I the only one interested in accessible, useful and user friendly 404 pages?"

Hardly! lol!

Four Steps to an Attractive 404.
Note: attractive varies with actual artist skill.

1. Create an attractive article in the Joomla! Article Manager to serve as your 404 page.

2. Create a menu item that links to the 404 article; alias of 404 could become http://example.com/404.html

3. Copy the error.php file to your template directory.

4. Copy this code immediately following the Restricted access line in your template's error.php.
if (($this->error->code) == '404') {
header('Location: http://localhost/fresh/404.html' );
exit;
}


+++

It's easy, Arno!  So, how have you done your 404's in the past?

Amy :)

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Fri Jan 11, 2008 10:41 am

So that will give me a 404 page in the search results me thinks, great :-)

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Fri Jan 11, 2008 2:55 pm

Arno -

You *are* using Joomla! differently than I am. You have said it many times, but now I get it. You push this little CMS to the virtual edge of the WWW! Me? I just try to use it.

I am humiliated to read your response and discover that I recommended you, a professional site developer, create a 404 page that could turn up in search results.

:-[

Allow me one more opportunity to redeem myself. I will re-read your brilliant, forward thinking post and look, again, at your example. Yes, SmashingMagazine, August 17, 2007. It's current. It's now. Something other professional web developers turn to for that little bit of something that noses them ahead of the pack. Sets 'em apart from the rest of us schmucks who have to think and creatively solve our problems.

One thing I *love* and *hate* about Smashing is how they have all of those examples stuffed into one page. Sometimes, I literally hear my computer chug through all of those bytes and links and images. On really large issues, I have (I SWEAR this is true) seen the lights dim, as energy normally used to heat and light my family home, is diverted for the purpose of guiding my geeky steps with breathtakingly brilliant leading edge approaches.

In the interest of time, I'll focus on the first example: 1. Appealing images.  In simplistic terms I might understand, does that basically mean a pretty picture? Maybe one of those in a piece of content and a few modules scattered across the page, perhaps? Could one of those modules be a search box, as the very first example shows? Could a menu be offered with a list of options?  Could the Latest News module be shared? Most read? List of authors? Heck. Gosh almighty. I can hardly contain my enthusiasm, but, dang it all, I think that might just work. NO REALLY! THAT MIGHT JUST WORK!

Dare I look at the second example: 2. Getting poetic I'll use their title - and apply my limited creativity (surely I can press out 17 syllables, right?):

404 error Haiku, by AmyStephen (aka Amy Stephen)

File not found? Oh no!
Whatever will I do now?
Try this page? Okay! 

Darn it. Toe stubbed, again. Here we are, having come full circle right back to the challenge you so correctly raised when you sarcastically dismissed my solution as inadequate. The search results! Why, even 17 syllables can be discovered and sucked into a search results page by Joomla!'s vacuum powered discovery capabilities.

Ooh-ooh-ooooh! (hand raised!) (you are probably to young to remember Arnold Horshack.) What about using the LoadModule Plugin deceptively positioned inside of the article in order to display those sweet 17 syllable solutions on the 404 page?

Would that work, Arno?

I'm probably just giddy and overly optimistic, but I think we might be able to use these for mentioned methods to also 3. Communicate through emotions.  as well as 4. Communicate through Irony. Scrolling ahead, and realizing, again, how you and I use Joomla! differently, I still cannot contain my optimism that, perhaps, even given the impossibility of the task you posed, that by harnessing the existing Joomla! framework as I described in my initial response, combined with these most recent ideas I respectfully submit for your discernment, ideas that I have suggested to you for implementing the very concepts in the article you identified as containing "some real creative 404 examples but whats more important, most of them have "inline" pages where navigation is still in place so people can just go on browsing your site", Arno, honestly, I believe we should be able to implement any of those fabulous ideas using Joomla!.

We are limited only by our imagination and are willingness to make things happen.

Amy

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Fri Jan 11, 2008 4:01 pm

You can make fun of it but I think a 404 doesn't belong in the search results thats all.

And, yeah your solution maybe a solution for some people and thats great, really, it just isn't for me sorry.

Quote
To one of the devs, would it be possible to at least make module rendering in error.php working like in the template index.php?

This is even more confusing:


Why would that be more confusing according to you? (serious question in case you think I am making fun of you which I don't!)

With that you will have the option to create a custom error.php and use modules like menu and search just like you do in template/index.php.

Is it wrong to push Joomla to the limits and with that maybe find new ways to do things or should everyone just go with joomla out of the box and accept whats being served, I almost get the feeling I'm doing something wrong?

Again, thanks for your input on the topic Amy.

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

User avatar
Pentacle
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 165
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: Custom 404 inside the content area

Postby Pentacle » Fri Jan 11, 2008 5:05 pm

if (($this->error->code) == '404') {
header('Location: http://localhost/fresh/404.html' );
exit;
}


Amy, shouldn't we let search engines know that this is a 404 response? So do you think this one can do it?

Code: Select all

header('Location: http://localhost/fresh/404.html', true, 404);




@Arno

This code is from administrator/components/com_login/admin.login.php

Code: Select all

function display()
{
   $module = & JModuleHelper::getModule('mod_login');
   $module = JModuleHelper::renderModule($module, array('style' => 'rounded', 'id' => 'section-box'));
   echo $module;
}


It shows the login module of backend. I think you can use something similar for 404 pages. Like this:

Code: Select all

foreach (JModuleHelper::getModules('user1') as $module)  {
    $module = JModuleHelper::renderModule($module, array('style' => 'rounded', 'id' => 'section-box'));
    echo $module;
}


-

Note that I haven't tried these and it's just opinion.
My Joomla! 1.5 extensions - http://ercan.us
Progress is made by lazy men looking for easier ways to do things.

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Fri Jan 11, 2008 5:11 pm

Thank you, Arno, for a response. That simple sign of respect means a lot to me.

No, it is never wrong to push Joomla! to it's limits. Frankly, I love problem solving and exploring new concepts and I find your questions to be interesting problems to solve.

You obviously care about our community and project and that is good foundation. It's also obvious you are disappointed in what our community has been able to deliver. Sometimes that happens; sometimes that should happen! There are effective ways and damaging ways to deal with disappointment. An effective way is to get more involved in the work and actually bring the improvements we want.

What can be damaging is to level one criticism after another without balancing those complaints with hours and hours of invested effort and appropriate recognition of what has been achieved. If the balance turns to primarily voicing complaints, then, even genuine concern for the welfare of the project starts to become attacking which discourages quality and progress.

It gets to be a viscous cycle and it's good to snap out of it.

Let's be sensitive to timing. At this very moment, as a community, we are testing. Final testing driving towards a release. Our activities are very focused on finding bugs and developing patches and testing patches and finding the next bug and developing the next patch and testing that one, too. We are getting ready to launch. Soon!

We will find quick response to our posts in Q&T that relate to that focus.

Yes, Arno, today, you can use these methods I explained and create a 404 page inside of the normal Joomla! content area that will not show up in the search results. You did get a solution to the question you raised, and given your skills it's not even a challenge.

Wilco and Andrew announced they are accepting white papers for any of us who want to suggest improvements for v 1.6. I think we can build on the excellent start provided by the error.php file and implement improvements into Joomla! core so that end users, without advanced knowledge of Joomla! and PHP, can click a few options and make this happen within their very own Joomla! Control Panel.  Nothing would make me happier, Arno, than to collaborate with you on this one little way we could improve Joomla!.

I see Ercan has posted in. Let me tell you what, Arno, if we have Ercan's help, we are in very good shape, indeed. I am confident he would also collaborate on a proposal and help code the dang thing, too!

Arno - You are someone I respect and care for.
Amy :)

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Fri Jan 11, 2008 7:18 pm

Amy, there wasn't any disrespect in the first place but your second post wasn't all that funny and not needed I think.

You ended the first one with:
It's easy, Arno!

On the edge of time getting my kids to swimming-school I posted what I thought of which was a 404 in the search results and maybe you missed it but there was a smiley behind it.

You could have said, dang I didn't think of that :-) <- smiley again or I know, thats one of the drawbacks how can we solve that?

You are right I am disappointed in a way and I think with me many front-end people that see how much Joomla is behind in delivering good html and css compared to modern standards, am I wrong about that? I may be critical at times but always with a warm but sometimes concerned hart for the project of which I am one of the founders so it sits deep in my system. The thing is that being critical stands for being negative in Joomla land it seems and I think thats sad and bad.

But lets move on we have things todo right.

Thanks for joining Pentacle, I'll see if I can run some tests over the weekend.

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Fri Jan 11, 2008 8:45 pm

Arno -

If I'm lucky, one out of a hundred ideas I have pans out. If the search were a problem, I would agree with you! But, I do not believe it is. Here are my ideas, again, for avoiding getting your 404 page into Joomla! search results:

1. Use an Image. You realize that was the first suggestion in the article you linked to? Now, why do you think they are using an image? Only because it looks better? I strongly suspect images are broadly used for 404 pages for exactly this reason: to keep the page out of a site search - and to keep the 404 page as part of the site.

2. Put the words into a module. Use LoadPosition to put it into an Article. Will the Article show up on a Search results page? I don't think so. Do you? Load the page with lots of great modules and an empty piece of content.

3. Here's a new idea! Use the I-Frame.  8)

Try it!

Amy :)

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sat Jan 12, 2008 11:33 am

Code: Select all

<?php
   foreach (JModuleHelper::getModules('main_menu') as $module)  {
       $module = JModuleHelper::renderModule($module, array('style' => 'xhtml', 'id' => 'section-box'));
       echo $module;
   }
?>


Does work in error.php so that opens a door, further testing.

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sat Jan 12, 2008 12:49 pm

Amy,

The information on an image is inaccessible (a screenreader for example will read the alt attribute but not the help text provided on the image itself) and an IFrame is inaccessible too so those are not an option for me.
The module in a content item would be an option maybe(haven't test it yet) but with the above I and anyone can just use error.php which is the most logical place to handle this like a normal Joomla! template.

I still think the best and most easy solution would be to be able to use:

Code: Select all

<?php if ($this->countModules('menu')) { ?>
   <jdoc:include type="modules" name="menu" style="xhtml" />
<?php } ?>


Instead of the code in the above message in error.php so hopefully that will be available in 1.6.

Other thoughts?

Arno

Good read on the topic http://www.ariadne.ac.uk/issue20/404/
Last edited by Jick on Sat Jan 12, 2008 12:56 pm, edited 1 time in total.
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Sat Jan 12, 2008 7:36 pm

Arno -

Great link, thanks!

The image, itself, serves as little more than "entertainment" and ALT tags can be used to address the accessibility issues. The real point is to make available MENUs and MODULES for site navigation. It was the first example on the link you shared of what you said you wanted to accomplish using Joomla! and it should be possible for those who want that option.

+++

Arno and Ercan and anyone else who wants to participate -

I was thinking. I believe the error.php file should go away.

We know the benefit of a single point of entry: a more elegant code base emerges allowing reuse of site functionality and the kind of flexibility that allows even that not yet conceived. When you think about it, it makes little sense to have another point entry point for a single purpose. It is limiting.

In fact, Arno, that is the exact point you are raising. The error.php file limits you. While adding module capabilities might make things better, it still isn't enough. What about the site that needs to automate the handling of the 404s? For a site migration, for example? Or, for permalink changes, as these system plugins start to emerge, providing better SEF URL options? Why waste precious developer resources making error.php stronger? Until it matches the strength of what we can do in Joomla!, someone, somewhere will come up with something else that is reasonable for error.php to do.

I think what we need to do is bring it back to Joomla!. Add additional configuration options that allow a site developer to specify what should happen for various system errors, including standard errors like 404, error codes that they want processed, and "other."

  • To keep things easy for the small implementation, a default set of messages and a default menu item should come preinstalled, in much the same fashion the error.php does now. In that sense, someone could ignore this completely, and 404's would automatically get a "Page not found" response in the component area of their standard site template. (Or, 500, or 403, etc.)
  • To keep the options as open as possible, the site developer should be able to indicate further processing (a component - menu item) that should be taken if this error code is discovered.
  • Then, when the router discovers an error, instead of routing to error.php, it could access this new configuration and direct, as defined.

On the searching side, it makes sense to improve searching, overall:
  • Add a parameter, at each level (global, menu item and article) to exclude from searching;
  • Add a parameter to the Search Module to include/exclude specific sections, categories and articles.

Responses?
Amy :)

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sat Jan 12, 2008 11:30 pm

Although I agree with the overall picture your drawing that things could be better I have some doubts or things that I question myself many times.

My templates are different from most Joomla templates at least by the fact that I split up index.php in chunks instead of packing everything in one file. Some templates I see have so many module checks and calculations to show or hide a sidebar, module position, change color, change width or whatever and because of that so much clutter of html that my head starts spinning on my body trying to read the structure.

I like things very clean and easy to manage so my template structure is something like this:
templates/mytemplate
-- html
---- my stripped down and cleaned-up override pack
-- css
---- multiple css files to separate structure and styling
-- js (if needed)
-- layouts
---- head.php (I have my own head file and hope the head will be part of the template in future J versions because I believe it belongs to the designer)
---- home.php (I have the ability to serve a different look for home)
---- default_page.php (I can create different page layouts for different sections)
---- footer.php
index.php
other files

As you can see for me an extra file like error.php or even a couple files like 404.php etc wouldn't matter because it keeps things clean.

The params you propose make sense but I think there needs to be a huge restructure and clean-up of the whole param system because I think there are way to many. Lots of params could be removed(usablity/simplicity gain big time) and become part of designing a template for a site. This goes hand in hand with fresh joomla native html and css.
This is my view and opinion of course, for me the more html is available for the designer the better and the less params/settings for the site/content manager the better.

Another thing with the params is that I think it would be great to be able to add params from the template trough being able to override or extend J native params if needed. My first thoughts on this are having a xml folder in the template folder just like the html overrides folder(or combine with the html folder).
In there you could have com_content/article/params.xml which will be rendered in the admin along with the other params. I think that will be very powerful, an example would be a param for language if needed for that site or a page specific style tag. (it should be just like the overrides right now, you can use them or not, be flexible)

I know this is a whole lot of info and ideas and they need good thinking trough but I wanted to let you know what is going on in my mind and why I for example can't easily say yeah thats a great option, adding those params. I think there is a lot of cleanup and rethinking todo for the whole Joomla params/template system. But I'm open for ideas of others and discussion of course.

I hope you see what I mean with this little insight in my [Do not buy our kitchens!] and mind.

Arno
Last edited by Jick on Sat Jan 12, 2008 11:54 pm, edited 1 time in total.
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sun Jan 13, 2008 8:29 am

Reading again this morning I thought I give a short version of the above to make it more clear maybe that the post was indeed a reply on your post :-)

1) I don't mind having more files in the template dir because it is more clear than putting everything in one file.
Files like: error.php (even 404.php etc), offline.php should be part of a standard joomla template.

2) I like the params but I think there are way to many params already in Joomla so before adding more it would be good to rethink and rework params. (extended ACL will probably need new params also so params needs a review anyway there maybe)

I don't know in which J version backward compatibility and legacy will be dropped to be able to make drastic changes but I asked Wilco in a comment on his latest blogpost about contributing. This is also important info to know before writing whitepapers I think.

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Sun Jan 13, 2008 4:52 pm

I was just thinking. I understood your post - thought it was great. This is a good summary, but a more in-depth look is good, too. While it is obviously impossible to solve all of it at once, it is all inter-connected and considering the wider perspective is important. If we want to get something done, though, we will have to focus specifically on 404s and try not to pull the string, unraveling too much.  ;)

This will likely expose me as "out of touch" -- but, I was looking at third party extensions on "searching" and found a few exist already, to restrict certain areas from search results. So, maybe adding this core functionality might have user support, already.

Thanks for sharing your template structure - side comment: you are ready to expand your services to the Drupal community. Your file system and methodology is remarkably close to their practices.

Given the concepts we are talking about, the error.php file could easily continue to exist within your template structure. If I understand your diagram, and I think I do, the error_php is currently used in lieu of your template's index.php. In this new scenario, the error.php file would be used in place of default_page.php (or, more likely, would simply become another layout in that file). Frankly, I think it would fit it with your organized approach to templating, nicely.

The point is that error.php would not be the entry point for processing - Joomla!'s main index.php would be the entry. That allows all of the logic and functionality contained within Joomla! to also be made available for this purpose.

It would be good to prototype of this that would accompany a white paper. Maybe first with core hacks, then see if it can be implemented as an extension that does not change core. As a third-party extension, these concepts could move forward more quickly and be tested by the community. Certainly, that type of feedback would make it easier to know if it should be included within the core.

I believe the plan has always been to drop backward compatibility in 2.0. I have heard nothing to the contrary so I am certain we can continue to count on that. Keeping that mind will be important, thanks. 

Arno - thanks.
Amy

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sun Jan 13, 2008 6:48 pm

Yeah there are lots of things related and interconnected that make things like this complicated, it easily feels like a temporary hack to me :-)

Right now my error.php lives in the template dir and it looks the same as the site and calling in the mainmenu module and I will have it call the search module. What I may end up doing or at least I will look at it is creating a menu called errormenu for example. That menu will have about three items, home, sitemap and search if I don't use the search module.

It could indeed be a layout(I will need to make another check and include) but on the other hand having a complete separate error file with the same options as index.php qua modules sounds great to me too and works just fine right now.

I wonder what one of the devs think about this discussion since they have deeper knowledge at framework level.

Side-note: I tried to port a template to Drupal 2 weeks ago and with the way I build it took me about an hour to have an exact look a like :-)
I've been also playing with drupal on a plugin/code level but I like the clear structure of Joomla for components, modules, plugins much better.
One of the first things I did was creating a separate admin theme for the Drupal admin because I find it highly confusing that frontend and admin look like one :-)

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

AmyStephen
Joomla! Champion
Joomla! Champion
Posts: 7056
Joined: Wed Nov 22, 2006 3:35 pm
Location: Nebraska
Contact:

Re: Custom 404 inside the content area

Postby AmyStephen » Sun Jan 20, 2008 5:03 pm

Need to consider 404 headers, as well. Something like this "if statement" should be considered for error.php since 404's are returning 200 responses to Google. (And, when I searched this problem, I found it is another common problem for 404's with CMSes.)
/**
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
?>
error->code == 404) :
header("HTTP/1.0 404 Not Found");
endif; ?>



Also, another great resource from A List Apart that I stumbled on.

Other than that, have had no time, at all, this past week to consider this further. Where does the time go?
Amy :)

0vermind
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 126
Joined: Tue Jun 05, 2007 10:12 pm

Re: Custom 404 inside the content area

Postby 0vermind » Sun Feb 03, 2008 1:19 am

do you know where this error.php is located? And more detailed steps to do this. I got lost when you said error.php. I'm not aware of such a page.

Thanks,
Mike

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sun Feb 03, 2008 2:24 am

Look in root/templates/system for the error.php file and copy that to your own template dir.

Once thats done joomla will use that file instead of the one in the system directory so you can tweak and tune it for your needs.

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4785
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: Custom 404 inside the content area

Postby ianmac » Sun Feb 03, 2008 3:33 am

I don't know what the correct way to do this would be, or even the best way, but one possible solution is to create a very basic custom component that would serve error pages.  By not building a search plugin, you can avoid it appearing in search results.  You could create a page for it in a hidden menu that would not show up.  THat way, you can attach all the modules you want to it.

It isn't pretty, but it would allow you to have custom 404s inside the mainframe, and the 404 page wouldn't turn up in the Joomla! search results.

There may be better ways to do it, like perhaps setting some sort of itemid and then rendering a template in your error,php, but I don't have the brain power to delve into that at the moment, so this is the best I could do.

Ian

User avatar
Jick
Joomla! Explorer
Joomla! Explorer
Posts: 355
Joined: Fri Aug 12, 2005 10:06 am
Contact:

Re: Custom 404 inside the content area

Postby Jick » Sun Feb 03, 2008 6:23 am

Ian,

How hard would it be to make module rendering possible in the error.php like it's done in index.php?

I have that working now with using plain php to get the modules instead of the load modules tag and it gives me all the flexibility I need.

1) I have a file called error.php in the template which is very clear what the purpose is of that file for designers/builders.
2) I can style it exactly like my template or if I want too a little or totally different.
3) I can load the menu module and the search module for example so visitors are given options to go on on the site.

I think files like error.php and offline.php should be standard in every template dir by default.

Arno
Joomla! professional services http://www.alvaana.com
http://moovum.com - Get Mollom Anti-Spam on your Joomla! website with Moovur
Follow twitter: @me_arno @jfoobar @moovum

0vermind
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 126
Joined: Tue Jun 05, 2007 10:12 pm

Re: Custom 404 inside the content area

Postby 0vermind » Mon Feb 04, 2008 11:52 pm

Can you give me some more information on how to include modules or whatever in the error.php. Cause if you just have a error.php created and custom make it will Joomla see that file and treat that as the error page?

User avatar
balam
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 240
Joined: Fri Oct 14, 2005 2:34 am
Contact:

Re: Custom 404 inside the content area

Postby balam » Tue Feb 05, 2008 1:47 am

great arguments and argumentation ( rethoric)
what is your final ideas in how to implement a 404 that fits the theme of the website.
the simpler the solution ( perhaps the better)
Art changes . . . lives change . . . we change.

0vermind
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 126
Joined: Tue Jun 05, 2007 10:12 pm

Re: Custom 404 inside the content area

Postby 0vermind » Wed Feb 06, 2008 9:15 pm

Agreed.  :D

I know a lot of PHP and Programming Skills but this. It's just plain confusing how it all works. It would have to be something like the index.php right? Because it has to call modules but if the error.php were to be called by an article it would already have the layout but then how do create the bridge (or link) from that to the menu to the error handler and back to modules so you can include the not found URL possible articles they might be looking for (based on what they typed as the directory or file) and a search box and help links to assist them.

Another question is how do you convert the call of Jerror that modules and helper.php seem to call when the component/article is not found.


Thanks,
Mike

User avatar
guysmiley
Joomla! Explorer
Joomla! Explorer
Posts: 497
Joined: Mon Sep 12, 2005 7:22 pm
Location: Ontario, Canada

Re: Custom 404 inside the content area

Postby guysmiley » Sat Mar 29, 2008 8:18 pm

Whew!

Now this was an interesting thread! So, in summary, there currently appears to be 3 options for handling 404s in J1.5 using sef.

1) customized error.php file called my template's index.php
- this appears to be problematic as the 404 error message will be searchable in your site
2) create a module with 404 text in it then call this module in the main body, redirected via error.php
3) employ a component like sh404 to handle url rewriting and 404 error messages

Are there any advancements since this thread went somewhat dormant?

ALSO, A question for Amy:
When using a script like:

Code: Select all

defined( '_JEXEC' ) or die( 'Restricted access' );
if (($this->error->code) == '404') {
header('Location: http://mysite.com/404-missing-content');
exit;
}


if the menu link to the errorURL is unpublished, the url won't resolve (using native j1.5 sef). Are there any suggestions on handling this? I don't want a button on my site that directs users to a 404 and I'm not sure I want to create a published link in a hidden menu (the only other way I could think of to handle this).

Any thoughts?

P.S. I'm trying out option #2 above as it seems to make the most sense to me - unless there's been further development in this area that I'm not aware of... :)

rodsdesign
Joomla! Intern
Joomla! Intern
Posts: 52
Joined: Tue Apr 17, 2007 2:11 pm

Re: Custom 404 inside the content area

Postby rodsdesign » Thu Jun 26, 2008 2:06 pm

Hi guysmiley,

were you able to accomplish #2? I would love to know the steps please :)

seems that would be a very helpful thing to have available!

Thanks...

Rod

User avatar
guysmiley
Joomla! Explorer
Joomla! Explorer
Posts: 497
Joined: Mon Sep 12, 2005 7:22 pm
Location: Ontario, Canada

Re: Custom 404 inside the content area

Postby guysmiley » Sat Jun 28, 2008 12:27 am

Yep,

But I later found out it was a bad idea. Read this:

HTTP status code

When a request is made for a page on your site, the server returns an HTTP status code in response to the request. Joomla! returns a '200 - the server successfully returned the page' for error pages. This is problematic for those working with Google Webmaster Services and trying to get a sitemap resolved.

If you want Joomla! to return a status code for the error, you can do so by adding logic before the DOCTYPE line, as follows:

Code: Select all

<?php
if ($this->error->code = '404') {
   header("HTTP/1.0 404 Not Found");
} ?>


From http://docs.joomla.org/Custom_error_pages

mderksen
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Sun Sep 03, 2006 9:23 am

Re: Custom 404 inside the content area

Postby mderksen » Sat Jul 19, 2008 11:04 am

If you want to do this correct... do it the following way:

Code: Select all

if (($this->error->code) == '404') {
header("HTTP/1.0 404 Not Found");
header('Location: ' . $this->baseurl . 'your-404-page.html', false ,404);
exit;

Read the PHP manual header function:
void header ( string $string [, bool $replace [, int $http_response_code ]] )

The optional $replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in FALSE as the second argument you can force multiple headers of the same type.

At last, the most important in my opinion:
$http_response_code.... without this code filled in your page might return a non 404 header. You can check yourselve with this url http://www.seoconsultants.com/tools/headers.asp. Type a non existing page on your domain and see how it works if you change the $http_response_code!

So... if you want to do it, do it right!


Return to “Joomla! 1.5 Bug Reporting”

Who is online

Users browsing this forum: No registered users and 3 guests