We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Plugin: SS Friendly 404

Development and Programming

George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

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.

Download the latest version | Documentation

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones

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.

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

Hi Derek, Thanks for the encouragement and for the tips. I’ll update the plugin when the clients stop bugging me and will post up again when it when done.

       
Derek Jones's avatar
Derek Jones
7,561 posts
16 years ago
Derek Jones's avatar Derek Jones
when the clients stop bugging me

See you in a few years! 😉

Sounds good, George, I look forward to seeing the update.

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

Version 1.1.0 of the Friendly 404 plugin is now available featuring:

  • Plugin updated to follow EE code guidelines
  • Results now parsed with template variables
  • Addition of {auto_path}, {count} and {total_results} variables

Updated download and documentation via the links at the top of the thread.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

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

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

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 😉

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

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

       
outline4's avatar
outline4
271 posts
16 years ago
outline4's avatar outline4

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

       
George Ornbo's avatar
George Ornbo
272 posts
16 years ago
George Ornbo's avatar George Ornbo

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’.

       
outline4's avatar
outline4
271 posts
16 years ago
outline4's avatar outline4

thanks for your explanations! I am trying to display content if sombody enteres certain links (that I actually know) and then display the new (updated) links.

well I guess I have to try to do this other than with your plugin. nice work though.

cheers stefan

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.