vBulletin 4 Template Syntax: Links
by
23 Aug 2009
This article was created by http://www.vbulletin.com/forum/member.php?u=224 on vB.com and reposted here with his permission: In vBulletin 4.0, we will support friendly URL for SEO and readability purposes. At the present, we support member, thread, and forum links. I expect that this list will grow to include albums, etc before the release date. You need to be aware of the new format for outputting these urls. TEMPLATES When you wish to use a url in a template the format is as follows: Code:
{vb:link string, array[, array][, string, string]} {vb:link [thread|member|forum], $threadinfo[, $pageinfo][, id, title]} The second argument is a string that notifies the system which type of URL is to be output. The valid types are thread, forum, and member The third argument is an array that contains the id and title, at minimum, of the link to be generated. For thread, this would be threadid and title. For forum this would be forumid and title. For member this would be userid and username. The fourth argument is an optional array that contains any arguments that are required to be sent along, such as perpage (pp), page (pagenumber), order, and so on. The simplest forms are: Code:
{vb:link thread, {vb:raw threadinfo}} {vb:link forum, {vb:raw foruminfo}} {vb:link member, {vb:raw userinfo}} Code:
{vb:link thread, {vb:raw post}, null, 'threadid', 'threadtitle'} If you wish to output a url that uses & instead of & for arguments, for javascript, append "|js" to your type argument so that thread becomes thread|js, member becomes member|js. If you wish to not output a sessionhash, in any instance, say for a url in an email, append nosession to the type argument, so that thread becomes thread|nosession EXAMPLES To output a link to a post, you could use HTML Code:
<a href="{vb:link thread, $threadinfo, $pageinfo_lastpost}#post$lastpostinfo[lastpostid]">$threadinfo[title]</a> PHP Code:
$pageinfo_lastpost = array('p' => 1234);
When creating a link in the code, use the fetch_seo_url function, which accepts the same arguments. function fetch_seo_url(string, array, array, string, string) In fact the {vb:link thread, $threadinfo, $pageinfo} syntax is just replaced with fetch_seo_url() when a template is compiled. EXAMPLES Infractions tab of a user's profile PHP Code:
$linkinfo = array('postuserid' => 123, 'postusername' => 'freddie');
Please be aware of this change and use it as needed in 4.0. Please refer to the code for exact examples if I have just confused you. |