Announcement

Collapse
No announcement yet.

Creating a Redirect Channel

Collapse
X
Collapse
  •  

  • Creating a Redirect Channel

    In older versions of vBulletin, you could specify a URL to redirect a forum to another location. This could be on your site or elsewhere. With the release of vBulletin 5, this functionality was removed. You can recreate this functionality using Template Hooks. I will outline the steps to create a channel redirect here.

    Note: This functionality is not available on vBulletin Cloud at this time.

    This tutorial involves changing options, creating custom templates and building a temple hook.

    Allowing Redirects

    To get started, if the destination link of your redirect is external to your site then you must allow vBulletin to redirect to the destination. This is done in the Options within the AdminCP.

    1. In the AdminCP go to Settings -> Options -> Site Name / URLs / Contact Details.
    2. Add the full URL of your destination to the Redirect Whitelist. For example: 'https://forum.vbulletin.com'
    3. Save this Options page.
    Click image for larger version  Name:	allow_redirect.png Views:	0 Size:	25.7 KB ID:	4433735

    Creating a Channel

    We need a placeholder for our redirect. To recreate the functionality from vBulletin 4, we are going to create that placeholder as a forum channel.

    1. In the AdminCP, go to Channel Management -> Add New Channel.
    2. Give it a name. For example: vB.Com Forums
    3. None of the other options really matter but you can give the channel a description if you wish.
    4. Save the channel.
    Click image for larger version  Name:	add_channel.png Views:	0 Size:	50.0 KB ID:	4433736

    On the resulting channel list, note the Node ID for the new channel. In my example it is 106.

    Click image for larger version  Name:	channel_list.png Views:	0 Size:	29.9 KB ID:	4433737

    Create a new template

    In order for this to work, we need to add a new custom template to your system. This is easy to accomplish in vBulletin.

    1. In the AdminCP, go to Styles -> Style Manager.
    2. In the row for your designated style choose "Add New Template" from the Choose Action drop down menu.
    Click image for larger version  Name:	style_manager.png Views:	0 Size:	47.1 KB ID:	4433738
    1. For the new template, give it a name. Example: forum_redirect
    2. Add the following code for the template:
    
    <vb:if condition="$nodeid==106">
    {vb:redirect 'https://forum.vbulletin.com'}
    </vb:if>
    

    Note: Make sure to change the nodeid (ex 106) to match the channel you created above.

    Click image for larger version  Name:	add_template.png Views:	0 Size:	30.8 KB ID:	4433739
    1. Save the template at the bottom of the editor.

    Code Explanation

    In order for this to work, the template uses two vBulletin Markup tags. <vb:if> and {vb:redirect}.

    The <vb:if> tag allows us to check if a variable has the proper value. you only want to redirect if the nodeid of the channel matches the one you specifically created. In my case the value is 106. This comparison allows for standard PHP Comparison Operators to be used.

    {vb:redirect} is a template method. This allows us to call a specific function within vBulletin's rendering engine to force a specific outcome. This method takes a URL as its parameter. If you're redirecting to a location within the vBulletin installation, this can be a partial URL. For instance to redirect to the Articles page you can use /articles as the parameter.

    Implement the Template Hook

    1. In the AdminCP go to Hooks & Products -> Manage Template Hooks.
    2. Click the "Add New Hook" link at the bottom of the list.
    3. Select a Hook location. Example: header_after_body_begin
    4. Give the hook a title. Example: vB.com Redirect
    5. We have to pass a variable to our new template for it to work. In the hook arguments field, add: nodeid=page.nodeid
    Click image for larger version  Name:	add_hook.png Views:	0 Size:	49.1 KB ID:	4433740

    A word on Hook Arguments

    Variables are not available to templates unless they are registered before the template is rendered. Normally, this is done in the PHP code. This is a security precaution so variables can be cleaned and processed before being shown to the end user. Since we have no PHP code for our new template, Hook Arguments allow us to pass one or more variables and register them. This allows us to use them in the template.

    There is no definitive list of all the variables available in vBulletin. Let alone a list of which variables are available to each template. If you need to know what variables are available, look at the parent template. To find the parent template, search the hook name in the AdminCP under Styles -> Search in Templates.

    Testing it Out

    After saving your template hook, the redirect should be functional. Visit the front-end of your site and click on the channel that you created. It should redirect to the specified destination.

      Posting comments is disabled.

    About the Author

    Collapse

    Wayne Luke A curious juxtaposition of nature, technology and sustainability. Find out more about Wayne Luke

    Article Tags

    Collapse

    beginner (3) channels (1) cloud (1) Custom (1) database (1) Google (1) howto (1) https (1) Intermediate (2) MYSQL (1) options (1) passwords (1) recovery tools (1) security (2) seo (1) sftp (1) ssl certificate (1) style (1) styles (1) template (1) tls (1) tutorial (2) users (1) vb5howto (5) vbcloud (1)

    Latest Articles

    Collapse

    • Creating a Redirect Channel
      by Wayne Luke

      In older versions of vBulletin, you could specify a URL to redirect a forum to another location. This could be on your site or elsewhere. With the release of vBulletin 5, this functionality was removed. You can recreate this functionality using Template Hooks. I will outline the steps to create a channel redirect here.

      Note: This functionality is not available on vBulletin Cloud at this time.
      This tutorial involves changing options, creating custom templates and building a temple hook. Allowi...
      Wed 5th Feb '20, 6:09pm
    • The Basic Anatomy of a vBulletin Page
      by Wayne Luke
      vBulletin 5's user output is created using a system of pages that are customizable by the site administrator. This system is called Site Builder. By breaking the system down into pages, a lot of control is given to the system administrator. By using Site Builder, you can create a unique site without any knowledge of HTML or CSS.

      vBulletin's pages are created using layers built upon a grid layout. Each page starts with a layout which defines the content areas of the page. Layouts define...
      Mon 11th Sep '17, 8:55am
    • Enabling Two-Factor Authentication
      by Wayne Luke
      vBulletin 5.3.0 and higher will allow site owners to enable Two-Factor Authentication for Administrator and Moderator functionality. This is an extra layer of security provided to make sure your user data remains as safe as possible. Two-Factor Authentication works in conjunction with an app on the user's smartphone, tablet, or computer. These apps provide a security token that lasts a limited time before expiring. The security token is created using industry standard algorithms and a unique string...
      Tue 4th Apr '17, 8:38am
    • How to moderate the posts of new users only
      by Wayne Luke
      To help combat spam, many users opt to have new user’s posts moderated until they’ve made a specific number of posts. This allows the Admin/Moderator team to keep potentially malicious posts out of the public eye until a user has effectively passed a ‘probationary period’ as a member of the site.

      In order to do this, you will need to create a custom usergroup and a promotion.

      Creating a Custom Usergroup
      First, you need to setup the usergroup for your non-Moderated...
      Wed 22nd Feb '17, 9:13am
    • Rebuilding the Sphinx index
      by Wayne Luke
      From time to time, we will need to update the indexing schema for the Sphinx server. In order for this fix to take effect, you will need to update the sphinx schema for the index. Follow these steps to rebuild your Sphinx Search Schema.
      1. Stop the Sphinx service on your server.
      2. Replace your existing Sphinx configuration file (vbulletin-sphinx.php) with the one provided in the current version of vBulletin 5 Connect. You can find this file in the do_not_upload directory.
      3. Update the file as provided
      ...
      Fri 3rd Feb '17, 1:01pm
    • Using the Search JSON
      by Dominic
      Using the advanced editor you can create powerful search modules. Following you find possible filters / parameters for using within these modules:
      The search JSON parameter has the following format:

      :
      { "filter": <value>, "filter": <value>, ... }
      <value> may be any valid string, number or JSON structure and will be interpreted by the specified filter. Filters not listed below are ignored.

      Filters

      The valid filters...
      Wed 28th Jan '15, 12:51pm
    Working...
    X