Phrase Text - integrate Xen Links

eriche

Member
Hello,

I struggle around to integrate in a Phrase links e.g. to Member Profiles and so on.

I am going to fetch userinformation from the DB - and want to Show a link to "Member_xyz" (which has DB ID 6).

I tryed following

HTML:
<a href="{xen:link 'members',6}">Member_xyz</a>

as well as

HTML:
<a href="{xen:link 'ROUTE'}">TEXT</a>
<a href="{xen:link account/upgrades}">upgrades</a>

But I always get the message

ERROR: Route {xen:link account/upgrades} could not be found. and so on,...

What do I miss?

Erich
 
That's not possible as the xen tags/functions are not rendered in phrases, what you have to do is pass the links as phrase parameters.

For XF's template:
Code:
{xen:phrase your_phrase_title, 'link={xen:link members, 6}'}

For PHP code:
PHP:
$something = new XenForo_Phrase('your_phrase_title', array('link' => XenForo_Link::buildPublicLink('members', 6)));

And your phrase content should be something like this:
Code:
<a href="{link}">Member_xyz</a>

P.S. There can be typos, so please double check the code.
 
@Mr. Goodie2Shoes you are Genius!
I think that I am missing some fundamental Basics - but I don`t have the Feeling this is well documented :censored:
Where could I read about this?

It is not 100% working
buildPublicLink('members', 6)
doesn`t work like supposed :(

I get redirected to the Members overview page, but not to a specific Members Profile.
Is maybe the UserID not correct? Should it be the Username? Or both together?

Where can I get all the "XenForo_Link" Options listed or explained :sleep:

Erich
 
yeah... I thought it wouldn't work :P
You'll have to pass an array as the build data:
PHP:
XenForo_Link::buildPublicLink('members', array('user_id' => 6));

XF template:
Code:
{xen:link members, {xen:array 'user_id=6'}}

You can also include the username so that the builder can include it in the URL.
 
yea! now it is working ;)

But again, how do I get this knowledge?
Would Need a list of all XenForo_Link Options (Parameters).

Next step I Need for sure, is linking to a Topic in PHP via XenForo_Link

Erich
 
Back
Top Bottom