Elvish Wanderer (aelana) wrote in s2component,
Elvish Wanderer
aelana
s2component

How to give yourself an error page...

I have a Default View on friends list that is empty and various friends groups that I read... I wanted to be able to alert people to this fact if they try to go to my friends page.
Another possible reason for this is to allert people to a friends only journal (i.e. going to the LastN page with no entries)

One way that works for the LastN page is a far distant past post that is publicly viewable, but that does not work for the Friends page because friends page only will show posts posted (not date on post) within the last two weeks.

So I did was overrid RecentPage:print and check for size $.entries of 0 (no entries) if not call page_layout if so display my erorr... and poof instant error page...

(note you have to create a custom theme, look at previous posts in this communitiy if you need a tutorial on that)..


function RecentPage::print() {
  var Page p;
  $p = get_page();

  if ((size $.entries) == 0) {
  """
	<!DOCTYPE html 
    	 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
		  <head>
                      <link rel="stylesheet" href="$.stylesheet_url" type="text/css" />
  """;
  print $.head_content;
  """
                     <title>Error</title>
                  </head>
                  <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
                  <table cellspacing="0" cellpadding="0" border="0" width="100%">
                 <tr><td colspan=5><img src="http://www.livejournal.com/palimg/component/clear.gif" width="1" height="3" alt="" border="0" /></td>
	         <tr>
		    <td><img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0" /></td>
  		    <td valign="top" width="99%">
  """;

  print_entry_header("<h3>Error</h3>");
  print_system_box_top();

  """
           
           PUT YOUR ERROR HTML HERE   
           

  """;  

  print_system_box_bottom();


  """
                    </td>
                    		<td><img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0" /></td>
  """;
  print_my_components($p);
  """
      		    <td><img src="http://www.livejournal.com/palimg/component/clear.gif" width="3" height="1" alt="" border="0" /></td>
                 </tr>
                  </table>
                  </body>
                </html>
  """;
  } else {
   page_layout($p);
  }
}
  • Post a new comment

    Error

    default userpic
  • 55 comments