1. 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

Discussion in 'XenForo Development Discussions' started by Valhalla, Apr 12, 2015.

  1. Valhalla

    Valhalla Well-Known Member

    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.)

            <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: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.
  2. Chris D

    Chris D XenForo Developer Staff Member

    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:

    {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:

  3. Valhalla

    Valhalla Well-Known Member

    Thanks, Chris.

Share This Page