Template Tags

Template Tags

Making sNews templates

A. Here we begin the basic “porting” steps with our index (template) file in order to get it working with sNews (you do need to have installed sNews). The first step is to take a copy of the file and rename it (if not already done) to index.php. As a precaution, re-name the default index.php file in your sNews package to XX_index.php. This disables it for now, so you can always re-name it back to index.php and run it if your ported file has problems.

these tags are for version 1.6 of sNews

B. We need to start the session (snews1.6 and earlier) and include the snews.php file which contains all of the CMS engine functions. Paste the following at the very top of your index.php:
(Make sure there is no space or blank line before the opening php tag)

snews1.6 and earlier

<?php session_start(); include (“snews.php”); ?>

snews1.7

<?php include (“snews.php”); ?>

C. The title function sets your page title and base directory. This function is critical in getting all the internal links to operate correctly. Insert it as the first line within your <head> area, and remove the static title string it replaces:

<?php title(); ?>

Now, sNews can work through your index.php to present site content.
To be able to display the site content, there some more functions that will need to be installed in index.php. Below is a list of the standard functions available:

1. Center function
Displays center articles and other main content on your page. Also, it’s used for displaying administrative area, archives, contact and other default main content. The number of articles you want to display on your front page is set in the administration area while logged in.

<?php center(); ?>

2. Menu articles function
Displays a number of new articles and/or past articles.Enter the nr of articles to start from and the amount articles to show: (eg: new articles would be (0, 3) in order to show the three first articles, or (4, 3) to show three articles starting from the fourth)

<ul><?php menu_articles(nr, amount); ?></ul>

!! Menu_articles items is nested in <li> </li> tags in sNews, which makes it very important to wrap this function within <ul> </ul> tags like in the above example.

3. Pages function
Displays links for page-type articles (added via the admin section) in the site’s main menu along with the default Home, Archive, Sitemap and Contact.

<ul><?php pages(); ?></ul>

!! Pages items is nested in <li> </li> tags in sNews, which makes it very important to wrap this function within <ul> </ul> tags like in the above example.

4. Categories function
Displays the categories added in the admin section. Home being the category used for frontpage publishing, by default.

<ul><?php categories(); ?></ul>

!! Categories items is nested in <li> </li> tags in sNews, which makes it very important to wrap this function within <ul> </ul> tags like in the above example.

5. New comments function
Displays new comments made to articles. Enter nr for number of new comments to show and amount for number of carachters.

<ul><?php new_comments(nr, amount); ?></ul>

!! New comments items is nested in <li> </li> tags in sNews, which makes it very important to wrap this function within <ul> </ul> tags like in the above example.

6. Search function
Displays the search form.

<?php search_form(); ?>

7. Breadcrumbs function
Displays breadcrumbs. That is, a set of links showing where you’re at in the site structure.

<?php breadcrumbs(); ?>

8. RSS function
Displays feeds for both articles, pages and comments by adding this to your index.php head tag:

<link rel=”alternate” type=”application/rss+xml” title=”RSS 2.0″ href=”rss-articles/” />
<link rel=”alternate” type=”application/rss+xml” title=”RSS 2.0″ href=”rss-pages/” />
<link rel=”alternate” type=”application/rss+xml” title=”RSS 2.0″ href=”rss-comments/” />

And then add the feed itself by either adding it in a link, like this:

<a href=”rss-articles/” title=”RSS feed”>RSS articles</a>
<a href=”rss-comments/” title=”RSS Feed”>RSS comments</a>
<a href=”rss-pages/” title=”RSS Feed”>RSS pages</a>

Or simply add the function call itself in the index.php:

<?php rss_links(); ?>

You decide what functions you want to use in your template. You do not need to use them all. When you now have the default sNews layout up and running, you might find that you want to have your own look and feel on the site. Then you’ll have to download one of many fine templates from users around the web, or why not try and make your own ? If you’re an experienced webdesigner you know how, and will succeed, but if you’re new to the whole concept of making websites, you might find the tutorial on making a template useful.

GET STARTED

sNews requires PHP, MySQL and mod rewrite. If your server meets those requirements, get started and learn how to install sNews on your website in 3 easy steps.

LEARN

Browse through our help center and learn about template tags and how to simply create your own theme. Dig into sNews and customize it to behave the way you want.

EXTEND

sNews can be a simple blog tool and a full blown CMS. Customize it with addons, mods or play with different themes.