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: sNews 1.7 Theme request  (Read 7428 times)

centered

  • Guest
sNews 1.7 Theme request
« on: January 19, 2009, 03:42:54 pm »

Just a quick request, why aren't theme writers making templates utilizing the subcategory menus?  I was expecting something utilizing some JS or cssplay solutions...

Logged

Sasha

  • Hero Member
  • *****
  • Karma: 28
  • Posts: 938
    • cssanarchy.com
Re: sNews 1.7 Theme request
« Reply #1 on: January 19, 2009, 10:20:34 pm »

once i build snews 1.7 template for NEWS site, submenu MUST..I prefer java script for that and that is easy to build....I hope equilni someone going to do that before i doo  ;D ....
Logged
Every morning, I get up and look through the 'Forbes' list of the richest people in America. If I'm not there, I go to work. | If you love your job, you haven't worked a day in your life. snews with ♥

centered

  • Guest
Re: sNews 1.7 Theme request
« Reply #2 on: January 28, 2009, 11:35:10 am »

Someone asked me that writing css for the category/subcategory menu doesn't work for 1.7 because the subcats doesn't show unless you are in the category.

Simple fix is to change this line with the second:
Code: [Select]
<?php
// if ($category_title == $categorySEF) { subcategories($parent); }
subcategories($parent); 
?>

All this is saying is if the selected category in the loop is equal to the category in the url, then show the subcategories of this category. This is not desired, so we will get all cats and subcats. 

Now,  I cleaned up the code for categories and subcategories. 
Description variable now includes the dash.  If it is empty the dash shouldn't show (bug).
Added the above to subcats.  Also added the row name to the title like the parent cats
Added some spaces and tabs for readability output html readability
Added unset and mysql_free_result to remove the variables from memory
Code: [Select]
<?php
// DISPLAY CATEGORIES
function categories() {
global $categorySEF;
$qwr = !_ADMIN 
' AND a.visible=\'YES\'' 
'';
if (s('num_categories') == 'on') {
$count ', COUNT(DISTINCT a.id) as total';
$join 'LEFT OUTER JOIN '._PRE.'articles'.' AS a
ON (a.category = c.id 
AND a.position = 1  
AND a.published = 1'
.$qwr.')';
} else {
$count '';
$join '';
}
$query '
SELECT
c.seftitle, c.name, description, c.id AS parent'
.$count.'
FROM '
._PRE.'categories'.' AS c '.$join.'
WHERE c.subcat = 0 
AND c.published = \'YES\'
GROUP BY c.id
ORDER BY c.catorder,c.id'
;
$result mysql_query($query);
if (mysql_num_rows($result) > 0) {
while ($r mysql_fetch_array($result)) {
$r['name'] = (s('language') != 'EN' 
&& $r['name'] == 'Uncategorized' 
&& $r['parent'] == 1
l('uncategorised'
$r['name'];
$class $r['seftitle'] == $categorySEF 
' class="current"' 
'';
if (isset($r['total'])) { 
$num '('.$r['total'].')'
}
$r['description'] = !empty($r['description'])
' - '.$r['description']
'';
echo '
<li>
<a'
.$class.' href="'._SITE.$r['seftitle'].'/" title="'.$r['name'].$r['description'].'">'.$r['name'].$num.'</a>
'
;
// if ($r['seftitle'] == $categorySEF) { 
subcategories($r['parent'], $r['seftitle']); 
// }
echo '
</li>
'
;
unset($r);
}
} else {
echo '
<li>
'
.l('no_categories').'
</li>
'
;
}
mysql_free_result($result);
}

function 
subcategories($parent$parentSEF) {
global $subcatSEF;
$qwr = !_ADMIN ' AND a.visible=\'YES\'' '';
if (s('num_categories') == 'on') {
$count ', COUNT(DISTINCT a.id) AS total';
$join 'LEFT OUTER JOIN '._PRE.'articles'.' AS a
ON (a.category = c.id 
AND a.position = 1 
AND a.published = 1'
.$qwr.')';
} else {
$count '';
$join '';
}
$subquery '
SELECT 
c.seftitle AS subsef, description, name'
.$count.'
FROM '
._PRE.'categories'.' AS c '.$join.'
WHERE c.subcat = '
.$parent.
AND c.published = \'YES\'
GROUP BY c.id
ORDER BY c.catorder,c.id'
;
$subresult mysql_query($subquery);
if (mysql_num_rows($subresult) !== 0) {
echo '
<ul>
'
;
while ($s mysql_fetch_array($subresult)) {
$class $s['subsef'] == $subcatSEF 
' class="current"' 
'';
if (isset($s['total'])) {
$num=' ('.$s['total'].')';
}
$s['description'] = !empty($s['description'])
' - '.$s['description']
'';

echo '
<li class="subcat">
<a'
.$class.' href="'._SITE.$parentSEF.'/'.$s['subsef'].'/" title="'.$s['name'].$s['description'].'">'.$s['name'].$num.'</a>
</li>'
;
}
echo '
</ul>
'
;
unset($s$parent$parentSEF);
}
mysql_free_result($subresult);
}
?>

« Last Edit: April 07, 2009, 04:10:59 pm by equilni »
Logged

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: sNews 1.7 Theme request
« Reply #3 on: January 28, 2009, 05:16:30 pm »

Thanks a lot Equilni
Just tested and it works great now.
Karma + 4 you

Poppoll
Logged

nuno

  • Jr. Member
  • **
  • Karma: 1
  • Posts: 52
Re: sNews 1.7 Theme request
« Reply #4 on: January 28, 2009, 05:46:37 pm »

Slightly off topic but didn't want to waste starting a new one -

I'm sure there used to be a fantastic green template for 1.7. I think it was one of the first ones posted here, as I say mostly in green with some circles/bubbles at the top?

Is it still around?
Logged

centered

  • Guest
Re: sNews 1.7 Theme request
« Reply #5 on: January 28, 2009, 05:51:10 pm »

Should of wasted a new thread instead.

No not sure
Logged

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: sNews 1.7 Theme request
« Reply #6 on: January 28, 2009, 05:51:52 pm »

Logged

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: sNews 1.7 Theme request
« Reply #7 on: January 28, 2009, 08:13:18 pm »

Still some errors

I have this in categories:
Templates
 - sub1
sNews
 -sub1
 
When I hover a submenu on the home page I see this in the status bar:
http://localhost/templates/test//sub1 = NOT correct in my case templates or sNews is missing between test and sub1

If I first click Templates than the subcats are displayed correctly:
http://localhost/templates/test/templates/sub1

PP
Logged

centered

  • Guest
Re: sNews 1.7 Theme request
« Reply #8 on: January 28, 2009, 11:33:00 pm »

Opps that's what i get for coding too early in the morning. Let me fix that.

Ok code above is fixed, let me know if you have issues.
« Last Edit: January 29, 2009, 12:04:14 am by equilni »
Logged

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: sNews 1.7 Theme request
« Reply #9 on: January 29, 2009, 01:13:28 am »

Yes yes yes thats it
Thanks
PP
Logged

centered

  • Guest
Re: sNews 1.7 Theme request
« Reply #10 on: January 29, 2009, 03:57:32 am »

Cool.
Logged

poppoll

  • Full Member
  • ***
  • Karma: 47
  • Posts: 199
    • Poppoll's sNews playground
Re: sNews 1.7 Theme request
« Reply #11 on: January 30, 2009, 12:54:22 am »

@equilni

Being busy...
First screenshots:
Horizontal Catmenu  added it after the pages()
Vertical Catmenu

PP
« Last Edit: January 30, 2009, 12:55:56 am by poppoll »
Logged

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: sNews 1.7 Theme request
« Reply #12 on: January 30, 2009, 01:03:05 am »

Cool.
Logged
Yes! I have no siggy.

nuno

  • Jr. Member
  • **
  • Karma: 1
  • Posts: 52
Re: sNews 1.7 Theme request
« Reply #13 on: February 03, 2009, 06:02:47 pm »

Thanks PP - One of the best designs I've seen on sNews. I hope to have a play around with it soon.
Logged