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 this in snews?  (Read 2726 times)

Boogada

  • Newbie
  • *
  • Karma: 3
  • Posts: 27
How to this in snews?
« on: October 03, 2007, 06:55:32 pm »

I'd like to try to use the Nautica 5 Theme I found on OSWD.org

Now it has a special way to present the date information, because it separates the time date from the content:

Code: [Select]
<div class="date">
          <span class="month">May</span>
          <span class="day">13</span>
        </div>

Content

With the css:

Code: [Select]
For the date:

.post .date .month {
  text-transform: uppercase;
  font: 700 1.0em arial, sans-serif;
  color: #888;
}

.post .date .day {
  display: block;
  margin-top: -5px;
  font: 700 2.1em arial, sans-serif;
  color: #888;
}

For the content:

.post p {
  margin: 0 0 0 3.5em;
  padding:  0 0 1em 1.2em;
  border-left: 1px solid #CCCCCC;
}


Is it possible to change the snews.php in a way that the date can be displayed like this?




Logged

line

  • Newbie
  • *
  • Karma: 1
  • Posts: 10
Re: How to this in snews?
« Reply #1 on: October 05, 2007, 10:11:20 am »

Hi. Also want to do the same with the default date of sNews.

I know it's possible because I saw an sNews-powered site having this. I've also found a thread with the same thing in mind, but the link provided by the "veterans" is from the old forum. 

Thanks, in advance guys.
Logged
"Living is easy with eyes closed. Misunderstanding all you see" - strawberry fields forever

pwendel

  • Full Member
  • ***
  • Karma: 8
  • Posts: 106
    • sNews 1.6 in Danish
Re: How to this in snews?
« Reply #2 on: October 05, 2007, 01:24:54 pm »

Hi,

This is one the tricky parts of adapting some types of template design to work with sNews - as you might have noticed templates with similar functionality like the one you describe above are usually released as a full package, not just the presentation layer.

One example is the (very nice) Zinfandel port by Fredrik Kylander: http://snewscms.com/forum/index.php?topic=5841.0

The reason for this is that it is not possible to style all of the center(); functions output without modifying the same function some - below is an example from the Zinfandel port:

Code: [Select]
Default snews.php, line 511 center function:

while ($r = mysql_fetch_array($result)) {
$infoline = $r['displayinfo'] == 'YES' ? true : false;

Same snip from Zinfandel snews.php:

while ($r = mysql_fetch_array($result)) {
echo '<div class="cal">'."\n".'<p class="postmonth">'.date('M', strtotime($r['date'])).'</p>'."\n".'<p class="postday">'.date('j', strtotime($r['date'])).'</p>'."\n"./*'<p class="postyear">'.date('Y', strtotime($r['date'])).'</p>'."\n".*/'</div>'."\n";
$infoline = $r['displayinfo'] == 'YES' ? true : false;


So you will need to add containers to the snews.php core and then match CSS from orignal template.

At least this should point you in the right direction :) Make sure you post your ports in the template section for all to admire ;)

Per.
« Last Edit: October 05, 2007, 01:31:30 pm by pwendel »
Logged
"Opportunity is missed by alot of people because it comes dressed in blue overalls and looks like hard work" -- Thomas Edison (1847-1931)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: How to this in snews?
« Reply #3 on: October 05, 2007, 03:28:26 pm »

I ran into this same problem when I ported Luka's Internet Sharing template to run with sNews 1.5.30. It was necessary to add a number of small mods within the center() function in the snews.php file. So, for that reason, I had to issue the template as a complete package with the modded engine file included.

To get the date to display with the day below the month, I used a custom-date generator for that part only (thanks to Mika). I then inserted the script into function center()... just before display of the article title begins. The title of each article is displayed within <h2> heading-tags.

To give you an idea of what it looks like and where it goes in function center()... I have modified your script (as you provided above) and inserted the custom date generators within them. The lines shown in red are the lines you would search for within your center function. The blue parts are what I added to your block of script:

Quote

if ($r['displaytitle'] == 'YES') {

   ?>
   <div class="date">
      <span class="month">
         <?php echo strtoupper(date('M', strtotime($r['date']))); ?>
      </span>
      <span class="day">
         <?php echo date('jS', strtotime($r['date'])); ?>
      </span>
   </div>
   <?php

echo '<h2>';
if (strlen($text) > $shorten) {
echo '<a href="'.db('website').$category.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a>';
} else {echo $r['title'];}
echo '</h2>';


NOTE: You might need to play around with the part you insert a bit... such as maybe adding a <br /> after the first closing span-tag to get a line-return. Or... perhaps... wrapping both spans within one set of <p> .......... </p> tags... then again... maybe not. I ended up using both to get mine to display properly.  :)
« Last Edit: October 05, 2007, 03:57:22 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

pwendel

  • Full Member
  • ***
  • Karma: 8
  • Posts: 106
    • sNews 1.6 in Danish
Re: How to this in snews?
« Reply #4 on: October 05, 2007, 03:52:51 pm »

That was some pro-advice right there :)
Logged
"Opportunity is missed by alot of people because it comes dressed in blue overalls and looks like hard work" -- Thomas Edison (1847-1931)

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: How to this in snews?
« Reply #5 on: October 05, 2007, 07:26:56 pm »

Nice! Snagged... thanks Keyrocks.

Karma is a good thing.
Logged
Yes! I have no siggy.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: How to this in snews?
« Reply #6 on: October 06, 2007, 01:52:08 am »

The only real difference between my code, used in the Zinfandel theme, and the one offered by key's is that mine also adds the year to the output, although in the basic edition, the year output is commented out. Don't really remember why at this moment. Plus mine uses <p>'s instead of <spans> for the very reason key's mentions (to break lines). Other than that, they're basically the same.

Quote from: my code
while ($r = mysql_fetch_array($result)) {
echo '<div class="cal">'."\n".'<p class="postmonth">'.date('M', strtotime($r['date'])).'</p>'."\n".'<p class="postday">'.date('j', strtotime($r['date'])).'</p>'."\n"./*'<p class="postyear">'.date('Y', strtotime($r['date'])).'</p>'."\n".*/'</div>'."\n";
Logged

Boogada

  • Newbie
  • *
  • Karma: 3
  • Posts: 27
Re: How to this in snews?
« Reply #7 on: October 06, 2007, 09:39:22 am »

First off thanks for your help. I've tried Keyrocks code and I had some little success. Well at least the date information is now shown like I think it should be. But I'm not yet happy with the content stuff, and the comments are overlapping with the content. Probably I have to place the containers a little different.
Logged

Boogada

  • Newbie
  • *
  • Karma: 3
  • Posts: 27
Re: How to this in snews?
« Reply #8 on: October 06, 2007, 10:03:52 am »

Also not only the comments are overlapping, there is "date" being shown there. I have no idea where that comes from. The second vertical line on the right side also comes from these things.

This is my current function center. I didn't do any CSS changes, I only adjusted the containers from the original theme.

Code: [Select]
// CENTER
function center() {
switch(true) {
case isset($_GET['category']): $id = $action = get_id('category'); break;
case isset($_GET['action']): $action = clean(cleanXSS($_GET['action'])); break;
case isset($_GET['articleid']): $articleid = get_id('articleid'); break;
}
switch(true) {
case isset($_POST['search_query']): search(); return; break;
case isset($_POST['comment']): comment('comment_posted'); return; break;
case isset($_POST['contactform']): contact(); return; break;
case isset($_POST['Loginform']): administration(); return; break;
case isset($_POST['submit_text']):
if ($_SESSION[db('website').'Logged_In'] == token()) {processing(); return;}
else {echo notification(1,l('error_not_logged_in'),'home');} break;
}
if ($_SESSION[db('website').'Logged_In'] == token()) {
switch ($action) {
case 'administration': administration(); return; break;
case 'settings': settings(); return; break;
case 'categories': admin_categories(); return; break;
case 'admin_category': form_categories(); return; break;
case 'articles': admin_articles('article_view'); return; break;
case 'extra_contents': admin_articles('extra_view'); return; break;
case 'pages': admin_articles('page_view'); return; break;
case 'admin_article': form_articles(''); return; break;
case 'article_new': form_articles('article_new'); return; break;
case 'extra_new': form_articles('extra_new'); return; break;
case 'page_new': form_articles('page_new'); return; break;
case 'editcomment': edit_comment(); return; break;
case 'files': files(); return; break;
case 'process': processing(); return; break;
case 'logout': session_destroy();
echo '<meta http-equiv="refresh" content="1; url='.db('website').'">';
echo '<h2>'.l('log_out').'</h2>'; return; break;
}
}
switch ($action) {
case 'archive': archive(); break;
case 'sitemap': sitemap(); break;
case 'contact': contact(); break;
case 'login': login(); break;
case '404': error404(); break;
default:
$article = get_id('article');
$title_not_found = '<h2>'.l('not_found').'</h2>';
$currentPage = strpos($article, l('paginator')) === 0 ? str_replace(l('paginator'), '', $article) : '';
$home = l('home_sef'); $categorySEF = get_id('category');
$categorySEF = empty($categorySEF) ? $home : $categorySEF;
$use_cat_id = $categorySEF == $home ? 0 : retrieve('id', 'categories', 'seftitle', $categorySEF);
$query_articles = "SELECT * FROM ".db('prefix')."articles WHERE published = 1 AND SUBSTRING(position, 1, 1) != '2'";
  if (!empty($article) && empty($currentPage)) {$query_articles .= " AND seftitle = '$article'";}
else if ($categorySEF == $home && s('display_page') <> 0) {$id_page = s('display_page'); $query_articles .= " AND id = '$id_page'";}
  else {
if (s('display_new_on_home') == 'on') {$query_articles .= $use_cat_id != 0 ? " AND category = $use_cat_id" : '';}
else {$query_articles .= " AND category = $use_cat_id";}
$query_articles .= " AND position <> 3 ORDER BY date DESC";
$result_articles = mysql_query($query_articles);
$numrows_articles = mysql_num_rows($result_articles);
if (!$result_articles || !$numrows_articles) {echo $title_not_found; return;}
else {
$articleCount = s('article_limit');
$article_limit = (empty($articleCount) || $articleCount < 1) ? 100 : $articleCount;
$totalPages = ceil($numrows_articles/$article_limit);
if (!isset($currentPage) || !is_numeric($currentPage) || $currentPage < 1) {$currentPage = 1;}
else if ($currentPage > $totalPages) {$currentPage = $totalPages;}
$query_articles .= " LIMIT ".($currentPage - 1) * $article_limit.", ".$article_limit;
}
}
$result = mysql_query($query_articles);
$numrows = mysql_num_rows($result);
if (!$result || !$numrows) {echo $title_not_found;}
else {
$link = '<a href="'.db('website');
while ($r = mysql_fetch_array($result)) {
$infoline = $r['displayinfo'] == 'YES' ? true : false;
$text = stripslashes($r['text']);
if (!empty($currentPage)) {$short_display = strpos($text, '[break]'); $shorten = $short_display == 0 ? 9999000 : $short_display;}
else {$shorten = 9999000;}
$comments_query = "SELECT * FROM ".db('prefix')."comments WHERE articleid = $r[id] AND approved = 'True'";
$comments_result = mysql_query($comments_query);
$comments_num = mysql_num_rows($comments_result);
$a_date_format = date(s('date_format'), strtotime($r['date']));
      $position = $r['position'];
$category = $r['category'] == 0 ? $home : retrieve('seftitle', 'categories', 'id', $r['category']);
$title = $r['title'];


if ($r['displaytitle'] == 'YES') {

   ?>
   <div class="date">
      <span class="month">
         <?php echo strtoupper(date('M'strtotime($r['date']))); ?>
      </span>
      <span class="day">
         <?php echo date('j'strtotime($r['date'])); ?>
      </span>
   </div>
   <?php
echo '<p>';
echo '<span class="title">';
if (
strlen($text) > $shorten) {
echo 
'<a href="'.db('website').$category.'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a>';
} else {echo 
$r['title'];}
echo 
'</span class="title">';  }
file_include(str_replace('[break]'''$text), $shorten);
$commentable $r['commentable'];
$edit_link $link.'index.php?action=admin_article&amp;id='.$r['id'].'" title="'.l('edit').' '.$title.'">'.l('edit').'</a>';
if (!empty($currentPage)) {
if ($infoline == true) {
$tag explode(','tags('infoline'));
foreach ($tag as $tag) {
switch (true) {
case ($tag == 'readmore' && strlen($r['text']) > $shorten):
echo $link.$category.'/'.$r['seftitle'].'/" title="'.l('read_more').'">'.l('read_more').'</a> '; break;
case ($tag == 'comments' && ($commentable == 'YES' || $commentable == 'FREEZ')):
echo $link.$category.'/'.$r['seftitle'].'/#'.l('comment').'1" title="'.l('comments').'">'.l('comments').' ('.$comments_num.')</a> '; break;
case ($tag == 'edit' && $_SESSION[db('website').'Logged_In'] == token()): echo ' '.$edit_link; break;
case ($tag != 'readmore' && $tag != 'comments' && $tag != 'edit'): echo $tag; break;
}
}
}
else if ($_SESSION[db('website').'Logged_In'] == token()) {echo '<p>'.$edit_link.'</p>';}
}
else if (substr($position01) != '2' && empty($currentPage)) {
if ($infoline == true) {
$tag explode(','tags('infoline'));
foreach ($tag as $tag ) {
switch ($tag) {
case 'date': echo $a_date_format; break;
case 'readmore':
case 'comments': ; break;
case 'edit': if ($_SESSION[db('website').'Logged_In'] == token()) {echo ' '.$edit_link;} break;
default: echo $tag;
}
}
}
else if ($_SESSION[db('website').'Logged_In'] == token()) {echo '<p>'.$edit_link.'</p>';}
}
}
if (!empty($currentPage) && ($numrows_articles $article_limit) && s('display_pagination') == 'on') {
paginator($categorySEF$currentPage$totalPages''l('paginator'));
}
if (!empty($article) && empty($currentPage) && $infoline == true) {
if ($commentable == 'YES') {comment('unfreezed');}
else if ($commentable == 'FREEZ') {comment('freezed');}
}}}}
echo '</p>';

Once again thank you guys.
Logged

line

  • Newbie
  • *
  • Karma: 1
  • Posts: 10
Re: How to this in snews?
« Reply #9 on: October 13, 2007, 12:47:07 pm »

Thanks, guys!

I've been waiting for the reply. I knew it has to be changed on the snews.php file but I just don't know what to change.

Nice explanation, Pwendel.

Thanks.


One more template problem down.!!! hehehe ;D
Logged
"Living is easy with eyes closed. Misunderstanding all you see" - strawberry fields forever