Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: [Tutorial] Custom Template: Part 1  (Read 2404 times)

centered

  • Guest
[Tutorial] Custom Template: Part 1
« on: December 01, 2009, 08:07:08 PM »

Before we begin, please stop and go to this site: http://snewscms.com/designers-guide/
The link is a base on how-to template tags and how to make a template.  You should read this first if you know nothing about how to make a template with sNews.  This should answer basic questions as this is not a basic how to

Ok some people may not like the default template that comes with sNews 1.7.  I happen to like it (I wonder why...), but let me get back on track.  So it was asked for a tutorial on skinning/customizing, or applying a customized theme to sNews. This is part 1 of how I would do a custom template or skin for sNews (as odd, wrong, weird it may be).

A Note about template customization. 
Quote
For full customization ability requires a rewrite of some of the public functions for sNews.  As sNews outputs it's own template for content, it can be hard for non or experienced PHP users to change up core functionality.  With this, I recommend that users that want full customization ability, to petition the devs to have sNews be written accordingly or just do it yourself and share with the community.

That said, let's continue.

To note:
Quote
Obviously to get a template working for sNews you don't have to do it this way at all. I am giving a way I would do it....

For the initial step, the goal is to get the initial set up to allow for a template with possible multiple arrangement.   With extras, we can add additional content to our template without having to do much work on the template itself.... Later, we will set up the file structure if we want seperate template sections, maybe a admin template if needed.

First, let's download sNews 1.7 and get everything up and running. There is information and a readme to help with it, so I won't go into detail.

Second, I apply this extra/Page fix here: http://snewscms.com/forum/index.php?topic=7996.0
Why?  It makes adding extra content to base pages easier.  It also adds the ability to hide/show the base pages

Third, onto the template:
 - I will add some extra() hooks so I can add additional content if needed.
 ---- Example  - under the header, under the center function, top of the sidebar, and before the footer.
 ---- Log in and create the extra groups based on the names of the extras you just assigned so we can add content if we need to

Quote
You can stop here.  Extra() gives you the ability to add content to whatever page you need to without extra coding. You can even add full sections like a sidebar in an extra

Fourth, I set the file structure to where I can focus on the template.

Trash
 - Readme and images folder gets trashed
 - SQL folder gets trashed

Create
 - Create 2 new folders - sN_template and sN_admin. The naming doesn't matter too much, as long as you remember it for the following steps.
 
Template Folder
 - Make a copy of index.php and rename it to base.php
 - Move base.php and the css folder into sN_template
 - Create a file called functions.php and index.php in the template folder
 - The template index.php should have this line at the top
 
Code: [Select]
<?php 
// For custom functions
include("functions.php");

include("base.php"); 

?>

- The base.php should not have the <?php include line and should have a path to the style sheet like so:
 
Code: [Select]
<link rel="stylesheet" type="text/css" href="sN_template/css/style.css" />
 

 For the root folder of sNews:
  - The root index.php should only have the following:
 
Code: [Select]
<?php 
include(
'snews.php');
include('sN_template/index.php'); 
?>


 Admin Folder
  - Move the language and js folders in the sN_admin folder
  - In snews.php, make sure you change the paths to the admin.js and the language files.
 
Whew, that was alot. What do we have so far?

Quote
snews17
 - index.php
 - snews.php
    /sN_admin
       /lang
        - EN.php
       /js
        - admin.js
    /sN_template 
        - index.php
        - base.php
        - functions.php
        /css
        - style.css

Why did I do this? The template is set up now to utilize a mod like this if needed. In addition, any additional functionality for the template can be put in a file outside of the core script.  While we are not working with the admin yet, the admin folder, in a way, get's me thinking of a separate admin template as I have the admin files segregated. 

Rest.

To note again:
Quote
Obviously to get a template working for sNews you don't have to do it this way at all. I am giving a way I would do it.... see the first line

Next in the series, I will pick a template and start making it into a sNews template. 
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [Tutorial] Custom Template: Part 1
« Reply #1 on: December 02, 2009, 09:19:49 AM »

1 reader here!
Bravo Jasequinu. 8)

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: [Tutorial] Custom Template: Part 1
« Reply #2 on: December 02, 2009, 09:55:36 AM »

Equilni,
A separate admin template would be a great idea.
PP
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [Tutorial] Custom Template: Part 1
« Reply #3 on: December 02, 2009, 04:26:33 PM »

I assume you're referring to Switherizer2... Where's the link to your Demo Bob?
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: [Tutorial] Custom Template: Part 1
« Reply #4 on: December 02, 2009, 04:50:19 PM »

Thanks Bob.
Switcherizer2 is definitely the most versatile approach to templating we've had yet.

Last week I updated a copy of my old 16 MEMU (version 1.1) package, which was using your 1st generation template system (site-wide template only) with the Switcherizer2 package (to version 1.2) with a few more mods added, including Phil's "Include Functions" mod and a completely re-written // ADMINISTRATION function to go along with a nicely-styled (I am biased of course) Admin template (pirated from an older pages-only project).

I did this for Patric... he's working on an Intranet project (using my 1.6 MEMU) and was looking for a way to have one very simple template to use for a simple 'start' template to use on home, showing only the latest articles leads. It worked out quite well, by creating a page titled "The latest news...", inserting only the insert-tag for lead articles -  [func]lead_articles:|:0,8[/func] - and setting it as the Home Page. The 'start' template also includes links to the login panel and a Welcome article, which shows in the site-wide template. Also made a slight change so that templates can be applied to specific categories (and subcategories).

Again... very flexible. Next, I want to get it running with a 1.7 project I've already added pages-in-cats & subcats to.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

centered

  • Guest
Re: [Tutorial] Custom Template: Part 1
« Reply #5 on: December 02, 2009, 05:05:43 PM »

Sven, thanks.  I will come full circle in a bit, keep reading. 

Pop, You got your wish: http://snewscms.com/forum/index.php?topic=8818.0

Bob, Yes I recall your mod, thank you.  I believe some had issues with it that needed reviewing and revising.  Have those been fixed since?

To all, the template switcher technique is similar to what I linked in the first post.  It is supposed to be version independent and easy to set up for a custom template situation.  In addition, for this tutorial, they key here not to use a modded core, or mod the core too much that would interfere with a users current setup.
Logged

Patric Ahlqvist

  • Nobodys perfect, but Im pretty effing close
  • ULTIMATE member
  • ******
  • Karma: 65
  • Posts: 4867
  • “I'm a self-made man and worships my creator.”
    • p-ahlqvist.com
Re: [Tutorial] Custom Template: Part 1
« Reply #6 on: December 02, 2009, 08:21:08 PM »

Bob, Yes I recall your mod, thank you.  I believe some had issues with it that needed reviewing and revising.  Have those been fixed since?

Seems to be working quite nicely, actually.
Logged
"It's only dead fish that goes with the flow... "
Updated

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: [Tutorial] Custom Template: Part 1
« Reply #7 on: December 02, 2009, 09:08:04 PM »

Thanks !  :D :D
PP
Logged