Guide to customview

Dec 20, 2002 11:31


It is possible to view a user's journal in a style that is not the current one selected in their customizations, using a URL of the form http://exampleusername.livejournal.com/data/customview/?styleid=number, for styles in the S1 style system, or http://exampleusername.livejournal.com/data/customview/?s2id=number, for styles in the S2 style system. (This will only work if user exampleusername has a paid, permanent or early adopter account.) Finding the style identifcation number for your style is explained here.

This is useful if you want to embed your journal into your home-page (as described in FAQ #68); if you're designing a custom style and want to see how it looks without actually setting your journal to it; or if you're testing to see whether someone's journal or friends page is messed up because of their style, their overrides, or a post with malformed HTML. It's also useful for any number of specialized things, like using frames in your journal.

This tutorial will show you how to access all the various features of the customview script.

Style System 1

The customview script can be used with styles of any of the four views (LASTN, FRIENDS, CALENDAR, or DAY); it will show the appropriate page of that journal. For example, http://news.livejournal.com/data/customview/?styleid=9488 will show the journal page for news as it would appear if it used Style #9488 (Generator) for its LASTN page; http://news.livejournal.com/data/customview/?styleid=9490 will show the calendar page for news as it would appear if it used Style #9490 (Generator) for its CALENDAR page.

It is only possible to preview a journal using an URL of the form http://exampleusername.livejournal.com/data/customview/?styleid=number if one of the following is true:
  1. Style #number is a system style. To see the list of system styles, go to the Style Browser and view styles owned by system.
  2. Style #number is owned by exampleusername. Any custom styles created on your account are owned by you. The style does not need to be public, in order to be used with customview.
  3. User exampleusername trusts Style #number. To mark a style as trusted, go to the Admin Console and type "set trusted_s1 number" (without the quotes), replacing number with the style ID number of the style you wish to trust. To mark multiple styles, list them with commas (and no spaces) between them: "set trusted_s1 number1,number2,number 3". This step is required for any non-system S1 style that you do not own.

Style System 2

The customview script can be used with any S2 style, but can only be used to show the main journal page. This is primarily useful for embedding your journal using JavaScript, as the customview script has the ability to return a JavaScript-encoded version of the journal. For normal use, it is easier to preview a journal in S2 by appending ?s2id=number to the end of the URL. This will work for any view of the journal.

It is only possible to preview a journal using an URL of the form http://exampleusername.livejournal.com/data/customview/?s2id=number if Style #number is owned by user exampleusername. Note that this must be the s2id number for a style, rather than a layer ID number.

Using the customview script

In order to pass information to the customview script -- information about which style to use, or which options to enable or disable -- you will use a query string. In a URL like "http://news.livejournal.com/data/customview/?styleid=9488&skip=2", the query string is the question mark ('?') and everything following it; that is, "?styleid=9488&skip=2". In this example, there are two parameters, "styleid" and "skip"; styleid takes the value "9488", and skip takes the value "2". Each parameter is assigned a value using an equals sign ('='); the parameter-value pairs are separated using ampersands ('&'); and the query string as a whole begins with a question mark ('?').

In a query string, the order of parameters doesn't matter; so, for example, "?styleid=9488&skip=2" is the same as "?skip=2&styleid=9488". (The question mark must always be first, and in each pair the parameter name must come before the value, but the pairs can come in any order.) Also, unrecognized parameters (or parameters with unrecognized values) are simply ignored; so "?styleid=9488&skip=2&blibberty=blar" is the same as either of the other two.

The information that customview will recognize in the query string is described below.
  1. Use the parameter "styleid" to specify an S1 style, or "s2id" to specify an S2 style. This is the only required element; it tells customview what style to use on the journal. (Without this, the journal will show the LASTN view in the user's default style.) Since S1 styles are view-specific, you will automatically be shown the correct view. S2 styles can only be used on the LASTN view using customview; to preview other pages in an S2 style, use the ?s2id=number option described above.
  2. Use the parameters "day", "month", and "year" to specify such. These are used if you're custom-viewing a DAY or CALENDAR S1 style. With a DAY style, all three parameters are required (but conveniently, both one- and two-digit day- and month-numbers will work; e.g., both 6 and 06). With a CALENDAR style, only "year" is recognized; this is optional if you want to view the current year, and required if you want to view other years. This has no effect for LASTN or FRIENDS styles or for S2 styles.
  3. Use the parameter "nooverride" with value "1" to disable overrides. This is optional for S1 styles, and will have no effect for an S2 style. (The default behaviour is to use overrides for S1 styles.) This is useful if you're not sure if a problem is resulting from your overrides or from your custom style (or from a combination of the two, or from neither). Using this, you can see how your journal/friends page looks using your overrides and a system style, or using your custom style ignoring your overrides. This is also useful if you're creating a custom style that you won't actually set to your own style for whatever reason, and don't want your own overrides to interfere with the style's appearance.
  4. Use the parameter "nohtml" with value "1" to escape HTML in entries. This is an optional parameter that will work for either style system, although it will only apply to LASTN or FRIENDS views. This is useful, again, for finding if a problem is with your style or overrides, or with a post (say, if its HTML is malformed); or, possibly, with a combination of the two, if HTML code in an entry is interfering with your style. For example, http://news.livejournal.com/?nohtml=1 will show the journal news as it would appear with all HTML escaped. Note that this only affects actual HTML in the original post: if auto-formatting is turned on (see FAQ #26), then LiveJournal will still create line breaks and linkify URLs; if LiveJournal-specific tags are used (see FAQ #75), then they will still apply; and if forbidden tags are used (such as ), they will be escaped rather than stripped.
  5. Use the parameter "checkcookies" with value "1" to have LiveJournal check for login cookies. (The default is not to check for them.) This is useful if you want to make sure private and protected posts behave the way you expect them to in a custom style that you're creating. If you are embedding your journal into your home page, note that private or protected entries may not show up for you even with this option enabled, because LiveJournal may not be able to access the cookies on your computer (it depends what mechanism you're using to embed your journal); so you'll want to test to make sure.
  6. Use the parameter "filter" to filter the friends page. (Note: this only works for viewing your own journal, and only works if you are using "checkcookies" with value "1".) This will work for an S1 FRIENDS style only, and will not work in S2. This option is for custom-viewing a FRIENDS style on your own journal; it allows you to specify a friends-group or combination of friends-groups to filter to, or to specify the friends page to be unfiltered. You can get the filter numbers for this by going to the Friends Filter page, checking the boxes for the friends groups you want to include, then clicking "View!"; the number you want will be in the address bar of your browser, after "?filter=". Use the value "0" for an unfiltered FRIENDS page. Customview will only recognize numerical filters, not their names; since filter=# works only for you and then only when you are logged in. FAQ #102 contains information about custom friends groups, if you need it.
  7. Use the parameter "skip" to skip a certain number of entries. This will work in either style system. This is useful if you're testing a LASTN or FRIENDS style to make sure your skiplinks behave the way you expect them to if you're not viewing the most recent entries. Note that skipping back using customview is subject to the same restrictions as skipping back in normal view (400 entries for LASTN, two weeks' worth of entries for FRIENDS).
  8. Use the parameter "enc" with value "js" to encode the page into a JavaScript document.write command. This can be useful in embedding; information on it can be found here. This will work for either style system.
  9. Use the parameter "tag" to filter to a specific tag. This will only work for custom-viewing an S2 style, since S1 does not have a tag view. If the tag has a non-public security level, you will need to combine this with checkcookies=1 for the preview to work.

contributed by ruakh and isabeau

~ customview

Previous post Next post
Up