Latest Register Log In

+ Advanced Search

Creating a Custom Template

Creating a Custom Template
By
09/25/03 (Edited 03/10/14)

Note: If you're adding a new section to your site (instead of overlaying on an existing page), you may prefer to use the Custom Pages system. Custom templates are more flexible, but also more complex than custom pages.

If you wish to add custom templates, this is a simple process. You can make an existing WSN page use a template other than the normal one, or you can add a new page which will use the WSN wrapper but will be otherwise new content.

At Admin Panel -> Themes -> Manage Templates, find the "Create a new custom template for multilingual called ___" area near the bottom and type a file name (like 'yourcustomtemplate') and click create. Your new custom template will automatically appear in the "custom templates" selector on the same page (or you can find it in the filesystem at templates/yourtemplateset/custom/yourcustomtemplate.tpl). Select it from the custom templates selector and click edit to begin writing the template. You may wish to copy in content from other templates, or from the toplist generator (Admin -> Themes -> Toplist Generator). You can use any HTML or global template variables.

Displaying

Link to custom template content using <a href="index.php?custom=yes&TID=yourtemplatefilename">Your Special Area</a>. If you want it to be a an alternate version of a preexisting area, just append custom=yes&TID=yourtemplatefilename to the URL of that area -- for example a custom member home template would be profile.php?custom=yes&TID=yourtempaltefilename.

If you want a specific category to have a unique template, just edit that category and fill in the template name in the 'custom template' field.

If for whatever reason you don't want the wrapper (header and footer) to show around your custom template, use &usewrapper=no at the end of your URL or place <!-- usewrapper=no --> in the template content.

Special Cases

Suppose you want to apply a custom template in a particular category. Instead of trying to change all the template links, you can just edit the category to specify a custom template to use for display, submit, edit etc in that category.

Title & Navigation

By default, the {NAVIGATION} trail and page title will say "Main" or whatever the title for the area you overlayed the custom template on is. You can set your own navigation bit and title by placing <!--Area: your title here --> anywhere in your custom template. That will Make the navigation show "Directory >> your title here" and the page title show "Directory: your title here" (or whatever is applicable to your navigation template and titles scheme).

You can also set titles (but not navigation bits) at Admin Panel -> Customizations -> Page Titles.

Enabling and Using Template Variables

All member variables for {THISMEMBER work in custom templates. Any type of toplist will work as well. If you wish to use a specific link, category, comment or member, just add it to the end of the URL of the page line this:

&linkid=1 (makes the link variables for link id #1 function on the page)
&catid=1 (makes the category variables for category id #1 function on the page)
&commentid=1 (makes the comment variables for comment id #1 function on the page)
&memberid=1 (makes the member variables for member id #1 function on the page)

As well, remember that the conditionals syntax works in custom templates the same as elsewhere.

SEO URLs

Suppose you'd like your custom page to have a nicer, shorter URL... you want it to be http://yoursite.com/mypage.html instead of http://yoursite.com/index.php?custom=yes&TID=custom-example. The easy way to do this is with URL rewriting, at Admin -> Settings -> SEO, using the rewriting individual URLs option.

On Windows IIS rewriting isn't available though, so you can fall back to opening notepad and typing this:
<?php
$custom = 'yes';
$TID = 'custom-example';
require 'index.php';
?>

Of course, change 'example' to the name of your template. Then save this file as mypage.php and upload it to your listings directory.

To use WSN templates outside of the directory where you have WSN installed, see Show Custom Template Anywhere.





Description Adding new tempalates to accomplish new tasks.
Rating
Views 4045 views. Averaging 1 view per day.