This plugin suggests relevant pages to users on your 404 page.
It is used in your 404 template and returns suggested weblog entries based on the final segment of the 404 URL.
You can specify which weblogs are used and set the limit on entries returned.
Example
{exp:ss_friendly_404 weblog=“news” limit="10"}
The plugin honours the search path preferences for each weblog.
Hey George, nice work, it’s a great idea. I just found it via Allard’s blog, didn’t catch your post here. Couple things would make this worthy of EllisLab giving some promotion to, first making sure that all of your variables are escaped in queries. Currently $weblog_name is not escaped. Second, instead of having its own output, why not just loop through the results, and parse search_results_url, url_title, and title with template variables? That lets the user control the markup and presentation. The indenting and whitespace usage is a bit different, and would need to be made to match the EE style guidelines in order for us to host the add-on, but I wouldn’t mind promoting it if those other two issues are addressed.
Version 1.1.0 of the Friendly 404 plugin is now available featuring:
Updated download and documentation via the links at the top of the thread.
Hi George,
Nice little plugin with a really great idea this one, well done.
Can I be bold though and ask how exactly the {if count == 1} part in your example code works when your plugin doesn’t actually set it anywhere? I’ve made a few plugins myself and have always had to code this using the prep_conditionals function or something like that if my memory serves correctly.
Just wondering how it does it really. Do plugins automatically exhibit a count then as it seems yours does 😉 although I’ve never been able to get mine to do that :down:
Again an excellent plugin this one and I’m sure will help a whole heap of people out.
Best wishes,
Mark
Hi Mark
It is set here
foreach ($query->result as $count => $row)
{
$tagdata = $TMPL->tagdata;
$row['count'] = $count+1;
// do stuff
}
This references the array key to set the count variable. Then the prep_conditionals function is called to make it available as a conditional.
$tagdata = $FNS->prep_conditionals($tagdata, $row);
I picked this up by dissecting the query module 😉
Hmm that’s truly weird.
I downloaded the 1.1.0 version from Google your latest version but somehow it had downloaded version 1.0.0
I’d not seen this thread until today so not really too sure what happened there? Just downloaded it now and I can see that it is a very much different version. All very weird. Now I can definitely see how it does it.
Weird that. Does Google do that then? Spit out old versions or something?
Best wishes,
Mark
hi there, I’m not shure if I got it right. I’ve placed the following code within my 404 template:
{exp:ss_friendly_404 limit="10"} {if count == 1}<ul>{/if} <li><a href= “{ auto_path}”>{title}</a></li> {if count == total_results}</ul>{/if} {/exp:ss_friendly_404}
now: I have a working link that is the following: http://www.mysite.com/news-events/ (it’s the news-events template) if somebody enters: http://www.mysite.com/news-events/news.html the 404 page is triggered. so your plugin should reveal the last 10 entries of the news-event template? is this correct?
well, in my case it displays nothing? it would be a very handy plugin for my site, since all links will be changed…
cheers stefan
The plugin gets the last segment of the 404 URL (in your case news.html) and does a SQL LIKE search on the title of weblog entries in your database. In this case it is looking for the string “news.html”. I suspect none of your entries have a title similar to this so hence no results are being returned.
The plugin is expecting ExpressionEngine URLs so it is not really setup to handle searches that include an html extension I’m afraid.
A good example would be if someone found a 404 page at http://www.example.com/newss it should return weblog entries with ‘news’ in the title. e.g ‘My News Page’, ‘Another News Page’, ‘A third news page’.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.