Register Members List Search Today's Posts Mark Forums Read

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

by Marco van Herwaarden Marco van Herwaarden is offline 23 Aug 2009

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

$pageinfo_lastpost would appear like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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.

Last edited by Dismounted; 23 Aug 2009 at 16:46..
Views: 7576
Reply With Quote
Comments
  #2  
Old 23 Aug 2009, 16:40
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
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?
__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #3  
Old 23 Aug 2009, 18:28
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Real name: Andreas

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Easy, eh?
Reply With Quote
  #4  
Old 23 Aug 2009, 19:19
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Real name: Sven
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

__________________
Please note that there will be no further updates to my addons, especially they will not be upgraded for vB5. I'm leaving vB, since IB choose to go the banana-way yet again.

http://www.roma-antiqua.de
Reply With Quote
  #5  
Old 04 Sep 2012, 22:11
ArsMagnum ArsMagnum is offline
 
Join Date: Apr 2012
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):


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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 04 Sep 2012, 22:55
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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
  #7  
Old 05 Sep 2012, 13:15
ArsMagnum ArsMagnum is offline
 
Join Date: Apr 2012
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 05 Sep 2012, 13:59
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Well, if you have a plugin I think you can just create your own array and register it to your template, like:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Reply With Quote
  #9  
Old 18 Nov 2012, 22:36
zero477 zero477 is offline
 
Join Date: Jan 2012
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



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Article Options

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


New To Site? Need Help?

All times are GMT. The time now is 07:07.

Layout Options | Width: Wide Color: