Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 4 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
vBulletin 4 Template Syntax: Links
Marco van Herwaarden
Join Date: Jul 2004
Posts: 25,415

 

Show Printable Version Email this Page Subscription
Marco van Herwaarden Marco van Herwaarden is offline 08-22-2009, 10:00 PM

This article was created by Freddie Bingham 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]}
link never changes

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}}
If you have an array containing the id and title but they do not follow the conventional naming conventions, then you may specify their names with the fifth and sixth options. Both must be specified for them to be recognized. For example, you have $post[threadid] and $post[threadtitle] and wish to output a thread url. You would use:
Code:
{vb:link thread, {vb:raw post}, null, 'threadid', 'threadtitle'}
null was specified for the $pageinfo argument array since this example had no arguments.

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>
$pageinfo_lastpost would appear like:
PHP Code:
$pageinfo_lastpost = array('p' => 1234); 
PHP

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');
$pageinfo = array('tab' => 'infractions');
$memberurl fetch_seo_url('member'$linkinfo$pageinfo'postuserid''postusername'); 
Using the mod rewrite output, $memberurl would be /members/123-freddie?tab=infractions

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.
Reply With Quote
  #2  
Old 08-23-2009, 03:40 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. I remember having that seen before, but I did not remember where.

The mod I have converted mainly has links to groups. In the quote linked by Dismounted Freddie hints that he expects that other forms of content would be added as development progresses. I'll ask over at .com whether that is indeed the case (or has anyone already done so?).

Ok, I just tried coming to grips with the linking function trying with the one link (to a members profile) that is eligible in this mod. So I totally failed with that. Looking at the code did'nt help me here, either. Perhaps anyone would be willing to enlighten me?

What I have is the username and the userid in an array that contains more data.
$example['usernane'] and $example['userid']. What would the code have to look like if I wanted to that users profile?
Reply With Quote
  #3  
Old 08-23-2009, 05:28 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$url fetch_seo_url('member'$example); 
Easy, eh?
Reply With Quote
  #4  
Old 08-23-2009, 06:19 PM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah - just not as easy

What messed me up so badly was the mixup of the new link method and the new way to pass variables to phrases, although thats pretty straightforward - once one sees through it.

What I needed was:
Code:
{vb:rawphrase by_x {vb:link member, {vb:raw example}, null, 'lastposterid', 'lastposter'}, {vb:var example.lastposter}}
Reply With Quote
  #5  
Old 09-04-2012, 09:11 PM
ArsMagnum ArsMagnum is offline
 
Join Date: Apr 2012
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello, I'm having a trouble.

I'm currently using vBulletin 4.2, and I want to generate a template link to a generic post (it depends on the post)...

So, I use this code (that I get from postbit template):

Code:
{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}#post{vb:raw post.postid}
However, the generated link is:

http://mypage.com/showthread.php?X-Thread-Title#p=YYY

Where X is the thread id and YYY is the post id, but, the link should be something like:

http://mypage.com/showthread.php?X-T...le&p=YYY#p=YYY

Anyone knows what could it be?

Thanks in advance =D...
Reply With Quote
  #6  
Old 09-04-2012, 09:55 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What template are you adding that to? If it's not a postbit template, then probably the issue us that pageinfo_post is not available there.
Reply With Quote
Благодарность от:
ArsMagnum
  #7  
Old 09-05-2012, 12:15 PM
ArsMagnum ArsMagnum is offline
 
Join Date: Apr 2012
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is a plugin that is added to the user info... Is for giving Like / Dislikes to posts...

That must be it... Is there another way to get the post link then?..

Thank You for your time by the way =D...
Reply With Quote
  #8  
Old 09-05-2012, 12:59 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, if you have a plugin I think you can just create your own array and register it to your template, like:
Code:
$pageinfo_post = array(
	'p' => $postid 
);
Of course I don't know if $postbit is the right variable, but you can change that to whatever you need.

Then if your plugin is rendering the template, call register('pageinfo_post', $pageinfo_post) before the call to render(). If you're putting that in an exitsing template, then you need ti call preRegister instead, like
Code:
vB_Template::preRegister('template_name', array('pageinfo_post' => $pageinfo_post));
Reply With Quote
  #9  
Old 11-18-2012, 10:36 PM
zero477 zero477 is offline
 
Join Date: Jan 2012
Posts: 59
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do someone knows how to get the link to someones user's profile picture?? I am trying to do a widget that shows the picture of the logged in user with a hello message... but cannot find how to display the user's avatar or profile picture.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:53 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04396 seconds
  • Memory Usage 2,294KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (7)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (1)post_thanks_box_bit
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete