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: [MOD] A separate template for the frontpage.  (Read 6934 times)

Joost

  • Guest
[MOD] A separate template for the frontpage.
« on: October 14, 2007, 01:28:42 am »

Lots of sites have a special design for the frontpage and a design for everything else. I believe this is an easy way to implement both designs in sNews, especially when you feel more comfortable with xhtml and css.

How it works:

Design two templates (or download the ones you like) and name them frontpage.php and everythingelse.php Insert the template tags you want (your choice), but don't insert:

Code: [Select]
<?php session_start(); include ("snews.php"); ?>This tag already exists in index.php, which we still need.

The 'new' index.php looks like this:
Code: [Select]
<?php session_start(); include('snews.php'); 
$uri $_SERVER['REQUEST_URI'];
 if (
$uri == '/' ) {
include ('frontpage.php');
 }else {
include ('everythingelse.php'); }
?>

In the second line you find '/', which means that 'frontpage.php' will show when index.php is in the root of the webspace. If you decide to install index.php in a subdirectory, change it to the name of the subdirectory, with a leading and trailing slash, like this:
'/subdirectory/'

I've made a small package, without the engine (snews.php). Don't get exicted. It is only an example to get you started and to show how this mod behaves. It is a simple mod and it is up to you to take advantage of it.

I've also included an .htaccess, that prevents visitors from directly accessing frontpage.php and everythingelse.php. It works for me, it might work for you.
« Last Edit: October 01, 2009, 12:20:46 pm by Joost »
Logged

Joost

  • Guest
Re: [MOD] A separate template for the frontpage.
« Reply #1 on: October 14, 2007, 03:24:04 am »

@Keyrocks,

I can't fully visualize the behaviour of this 'mod merge' .  As I understand, Bakercad's mod is supposed to work site wide. It looks like the frontpage won't be affected by changing the settings. Am I right?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: [MOD] A separate template for the frontpage.
« Reply #2 on: October 14, 2007, 04:00:31 am »

Honestly Joost... it was a dumb suggestion with absolutely no testing done to confirm it... which is why I deleted the dumb thing now and have gone to have a much-needed sleep...zzzzzzzz   :P
« Last Edit: October 14, 2007, 04:05:17 am by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Joost

  • Guest
Re: [MOD] A separate template for the frontpage.
« Reply #3 on: October 14, 2007, 04:10:51 am »

Goodnight Doug. ;)
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: [MOD] A separate template for the frontpage.
« Reply #4 on: October 15, 2007, 09:36:33 am »

Hi i ask for this in topic http://snewscms.com/forum/index.php?topic=6111.0
so far i think is working and i can have different templates for its one page or articles
my setup for index is like this
Code: [Select]
<?php
if (($_SERVER['REQUEST_URI']) == '/like/' ) {
include_once(
'html/index.php');
}
if ((
$_SERVER['REQUEST_URI']) == '/like/contact/' ) {
include_once(
'html/contact.php');
}
else{
include_once(
'html/therest.php');
}
?>


demo is off
different html is index, contact, and all the other is normal
« Last Edit: October 16, 2007, 11:20:09 am by sibas »
Logged

theroach

  • Newbie
  • *
  • Karma: 0
  • Posts: 8
Re: [MOD] A separate template for the frontpage.
« Reply #5 on: February 04, 2008, 07:02:56 pm »

Im using Keyrocks MESU 1.6 version of  Snews. I tried copying and pasting code to get this to work on it but didnt have any luck.

Heres the code from the MESU version:

Code: [Select]
<?php session_start();
include (
'snconfig.php');
# Location: root
# The rest of the template is now located in index.php in active tempate folder in templates directory.

 
if(file_exists('templates/'.s('template').'/index.php')){
        include(
'templates/'.s('template').'/index.php');
    }
    else{
# Use this string when global dbase table values are activated in snconfig.php.
        
mysql_query("UPDATE ".db('prefix')."".gl('settings_table')." SET value = 'default' WHERE name = 'template'");
        
// mysql_query("UPDATE ".db('prefix')."settings SET value = 'default' WHERE name = 'template'");
        
include('templates/default/index.php');
    }

?>

any ideas on how i could get this to work with this version?
Logged

Joost

  • Guest
Re: [MOD] A separate template for the frontpage.
« Reply #6 on: February 04, 2008, 11:47:09 pm »

Here is the code. Not tested.

- If index.php resides in a subfolder, you will still have to edit line 7 ($uri == '/' ).
- If it works as expected, you won't be able to switch the homepage in the database. It is a different template, but fixed.

Code: [Select]
<?php session_start();
include (
'snconfig.php');
# Location: root
# The rest of the template is now located in index.php in active tempate folder in templates directory.

$uri $_SERVER['REQUEST_URI'];
 if (
$uri == '/' ) {
include ('frontpage.php');
 }else {

  if(
file_exists('templates/'.s('template').'/index.php')){
        include(
'templates/'.s('template').'/index.php');
    }
    else{
# Use this string when global dbase table values are activated in snconfig.php.
        
mysql_query("UPDATE ".db('prefix')."".gl('settings_table')." SET value = 'default' WHERE name = 'template'");
        
// mysql_query("UPDATE ".db('prefix')."settings SET value = 'default' WHERE name = 'template'");
        
include('templates/default/index.php');
    }
 }
?>
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] A separate template for the frontpage.
« Reply #7 on: October 01, 2009, 08:43:40 am »

(...)

I've made a small package, without the engine (snews.php).
Don't get exicted.
I was. ;D
But there's no file there.
This mini-mini Mod should work without any .htaccess, shouldn't it?
I tried in a cascading index page, but allways land on "journal" ???. Look:
1st index:
Code: [Select]
<?php session_start(); include ("snews.php"); ?>
<?php if ( $_SESSION[_SITE.'Logged_In'] == token()) {include('admin.php');} else {include('index2.php');} ?>
2nd index:
Code: [Select]
<?php
if (($_SERVER['REQUEST_URI']) == '/' ) {
include_once(
'home.php');
}
else{
include_once(
'journal.php');
}
?>

Weirdo. :-\

Joost

  • Guest
Re: [MOD] A separate template for the frontpage.
« Reply #8 on: October 01, 2009, 12:50:05 pm »

(...)

I've made a small package, without the engine (snews.php).
Don't get exicted.
I was. ;D
But there's no file there.

That webspace came with a pallet beer. Link updated.

I tried in a cascading index page, but allways land on "journal" ???. Look:
1st index:
Code: [Select]
<?php session_start(); include ("snews.php"); ?>
<?php if ( $_SESSION[_SITE.'Logged_In'] == token()) {include('admin.php');} else {include('index2.php');} ?>
2nd index:
Code: [Select]
<?php
if (($_SERVER['REQUEST_URI']) == '/' ) {
include_once(
'home.php');
}
else{
include_once(
'journal.php');
}
?>

Weirdo. :-\

If you use both code snippets, one might overrule the other. You will have to merge both conditionals.
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] A separate template for the frontpage.
« Reply #9 on: October 01, 2009, 04:54:26 pm »

If you use both code snippets, one might overrule the other. You will have to merge both conditionals.
Ah ah!
Merging the 2 conditions?
Oh oh!
I just learned how to manage A condition.
2 now?
This gonna be a giant step for the inspecteur.
1st I need my magnifying glass.
I fetch it and then come back to tell the world inspecteur Sven made it.
See ya.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] A separate template for the frontpage.
« Reply #10 on: October 01, 2009, 05:03:38 pm »

Code: [Select]
<?php if ( $_SESSION[_SITE.'Logged_In'] == token()) {include('admin.php');} 
elseif ((
$_SERVER['REQUEST_URI']) == '/' ) {
include_once(
'home.php');
}
else {
include_once(
'journal.php');
}
?>

Is this the merging?
No result here (allways the Journal). :P
Over.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD] A separate template for the frontpage.
« Reply #11 on: October 01, 2009, 05:24:12 pm »

Sven ... Joost fixed a similar problem for me over here. It hasn't been presented as a mod yet, but if you're interested I can show you the code I'm using on inkpattern.com, to have a special cover page and normal category/article/page pages. Unless of course you get this merging of conditions running. And the wall built. ;)
Logged

Joost

  • Guest
Re: [MOD] A separate template for the frontpage.
« Reply #12 on: October 01, 2009, 05:27:54 pm »

I'd like to help out, but I am almost off to work.
And I am also in the middle of building a concrete, soundproof wall around my wife.
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: [MOD] A separate template for the frontpage.
« Reply #13 on: October 01, 2009, 05:36:14 pm »

Sven ... Joost fixed a similar problem for me over here. It hasn't been presented as a mod yet, but if you're interested I can show you the code I'm using on inkpattern.com, to have a special cover page and normal category/article/page pages. Unless of course you get this merging of conditions running.
Thanks fot the link, Fred.
I'm gonna read it and try carefully to make it work.
Quote from: Fred K (agentsmith)
And the wall built. ;)
Quote from: Joost
And I am also in the middle of building a concrete, soundproof wall around my wife.
;D