• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Defining link parameters in template

Valhalla

Well-known member
#1
Is is possible to define a link parameter as I have suggested below to set a title when creating a new thread. The code modifies the Post New Thread link to include a "title" parameter.

(Taken from the forum_view template.)

Code:
        <xen:set var="title">0</xen:set>
     
        <xen:if is="{forum.node_id} == 10">
          <xen:set var="title">title=A%20Test%29Title</xen:set>
        </xen:if>
    <xen:set var="$newDiscussionButton"><a href="{xen:link 'forums/create-thread', $forum, $title}" class="callToAction"><span>{xen:phrase post_new_thread}</span></a></xen:set>
The above code wouldn't work, but it is to illustrate what I'm trying to do. $title would only exist in some cases.
 

Chris D

XenForo developer
Staff member
#2
The third parameter of the link builder accepts an array, or a simple string that is automatically converted to an array, so the correct syntax would be:

Code:
{xen:link 'forums/create-thread', $forum, 'title=Test title'}
It's not much different from what you already have, though, but really it should produce a link like this:

/forums/forum-name.12/create-thread?title=Test+title