Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: [How-To] create a Single Page Website using sNews 1.7  (Read 1850 times)

GerryMacOstair

  • Newbie
  • *
  • Karma: 2
  • Posts: 7
    • Gerry's home page
[How-To] create a Single Page Website using sNews 1.7
« on: September 11, 2014, 03:11:33 AM »

This is an answer of sorts to this thread http://snewscms.com/forum/index.php/topic,9055.0.html by nukpana. There certainly are different approaches thinkable to create single-page websites w/ sNews, but I do think that this one is the simplest (if probably not the most elegant one).
Use "articles" to feed your content to the system (database). Allow as many articles to be displayed on your home page as you need. Don't let the titles be displayed so you have more control over structure and layout. Write the titles and content directly into individual articles, and wrap them with the structure tags necessary to keep the page valid. For the standard sNews package use
Code: [Select]
<div>, for HTML5 variants use
Code: [Select]
<section> and
Code: [Select]
<article>. This way, you are not at risk of making a mess of the engine file (snews.php).

Your various chunks of content will be displayed via the "center" function. You can sort them easily via the "time of publication" feature (which you enable but don't want to have displayed). Add "id" values to your
Code: [Select]
<section> tags (HTML5) or your individual outer
Code: [Select]
<div> tags (XHTML) so you have anchors for the navigation.

If you want a contact form displayed on this same page (which you probably will), create another article, set the time of publication to the earliest date (if you want it to appear at the end of the page), and insert the proper structure tags and use the "insert function" available from the editor. Insert "contact" (w/o quotes) in the first popup dialog and leave the second one empty. Remove the function shortcuts you don't need on a single page website (breadcrumbs/pages/articles/comments/rss links). Design the page with CSS.

That much for the easy part. Now, there is a peculiarity of single page sites that needs some consideration as it usually is not an issue in standard packages. We don't have a single "contact page" that would be displayed, once some visitor navigates to this form. This will cause a fine mess as soon as the form will be submitted. Whether the message will be sent successfully or an error occurred, there will appear a response to inform the visitor as to whether the process was completed or not. This message would appear on the contact page. Since we miss it, it appears in the area governed by the "center function" (where all our other chunks of content used to be). This may cause the visitor to get stuck, especially in cases of failed transmission. The "return" link would point to the contact page we don't have.

To mend this, it is, after all, necessary to fiddle (a little bit) with the engine file. So make a backup of what you already have, and open snews.php in your ASCII editor of choice.
Look for this string
Code: [Select]
function contact() and scroll down until you get to the notification
Code: [Select]
'contact_sent' and remove the word
Code: [Select]
home from this code line so that you have only the two single quotes left. The line will then end in
Code: [Select]
sent'),'');.
The scroll further down to find the notification
Code: [Select]
'contact_not_sent' and remove the word
Code: [Select]
contact, so this line also ends in
Code: [Select]
sent'),'');. Then set your cursor before the semicolon and add
Code: [Select]
.' '.l('message_error'). This will put out a (somewhat) comprehensible choice of reasons for the failure to the visitor. Save the file.
Now open the file "EN.php" in your "lang" directory and find
Code: [Select]
$l['contact_sent'] and add
Code: [Select]
<a href="./">Please reload this page</a> to the message. The go to
Code: [Select]
$l['message_error'] and do the same. This will give inexperienced visitors an easy way to make the page display as it should again.

As it turned out, this description is quite lengthy. This was not my intention. Here's hoping this little tutorial will be useful to someone.
Oh, and if you get stuck with a series of failed message submissions, you might want to try this; at any rate, it did work for me.
Go to snews.php and find in
Code: [Select]
function contact() this line
Code: [Select]
&& $name && $mail && $message && checkMathCaptcha()) { and change it to read
Code: [Select]
&& $name && $mail && $message && checkMathCaptcha==true) {.
Here's visual proof: http://macostair.net/

Regards, Gerry
Logged

sibas

  • Hero Member
  • *****
  • Karma: 24
  • Posts: 535
    • simply4all a social directory
Re: [How-To] create a Single Page Website using sNews 1.7
« Reply #1 on: September 11, 2014, 09:45:43 AM »

Nice one! I like your single page and I added to The list;D

Keyrocks

  • Doug
  • Administrator
  • ULTIMATE member
  • ******
  • Karma: 451
  • Posts: 6288
  • Semantically Challenged
    • snews.ca
Re: [How-To] create a Single Page Website using sNews 1.7
« Reply #2 on: September 11, 2014, 06:48:41 PM »

@Gerry - I REALLY like your single-page approach using sNews 1.7 and your template (theme) is - quite simply - refreshingly 'outside-the-box'.  Well Done! :)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

GerryMacOstair

  • Newbie
  • *
  • Karma: 2
  • Posts: 7
    • Gerry's home page
Re: [How-To] create a Single Page Website using sNews 1.7
« Reply #3 on: September 12, 2014, 04:38:36 AM »

Thank you, gentlemen, very kind of you. @sibas: Thanks for adding me to the list. @Doug: Glad, you like it.

Cheers,
Gerry
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 74
  • Posts: 751
Re: [How-To] create a Single Page Website using sNews 1.7
« Reply #4 on: September 15, 2014, 12:54:32 PM »

Awesome work Gerry.  I love the site!
Logged

GerryMacOstair

  • Newbie
  • *
  • Karma: 2
  • Posts: 7
    • Gerry's home page
Re: [How-To] create a Single Page Website using sNews 1.7
« Reply #5 on: October 04, 2014, 05:21:51 PM »

Thanks, nukpana. I'm sorry for the late reply, but I was busy with http://snewscms.com/forum/index.php/topic,11038.0.html and other stuff. You know, life is always getting in the way ...

Regards,
Gerry
Logged