Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Get started at 1.7RC and i have some Q ab menu_articles  (Read 2549 times)

xper

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Get started at 1.7RC and i have some Q ab menu_articles
« on: July 12, 2008, 07:12:28 pm »

// so sorry if is wrong board   is not Issues and bugs for RC version

Get started at 1.7RC
and i have some Q

in function menu_articles


function menu_articles($start, $size, $cat1, $cat2, $catchall) {

( i'm try to search but is not 1.7 version )
http://snewscms.com/forum/index.php?topic=4177.0


how to get it into 1.7RC ?

thank you.

regard. :)
« Last Edit: July 12, 2008, 07:19:37 pm by xper »
Logged

Joost

  • Guest
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #1 on: July 12, 2008, 08:54:43 pm »

I haven't got a clue what it is you want, can you explain?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #2 on: July 13, 2008, 12:57:36 am »

@ Joost... I think he wants to apply the Getting recent articles from one specific category mod that Bakercad created for Fred K. last year (for 1.6) to 1.7RC. The functions and Bakercad provided likely won't run in 1.7RC since the queries (at least) are different. I am not familiar with this mod and do not have time to do it.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

xper

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #3 on: July 13, 2008, 06:20:53 am »

i'am try  to add in 1.7 doesn't work  ^^''
Logged

Joost

  • Guest
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #4 on: July 13, 2008, 10:15:54 am »

OK, here is a modified function menu_articles for 1.7
It is fully untested. I let you have the honour of doing so.

In snews.php, replace function menu_articles with the following:



Code: [Select]
<?php # don't include "<?php" or "?>"

function menu_articles($start = 0, $size = 5, $cat ='') {
 if !empty($cat) $cat = 'AND category  in ('.$cat.') ';
$query = 'SELECT
title,a.seftitle AS asef,date,
c.name AS name, c.seftitle AS csef,
x.name AS xname,x.seftitle AS xsef
FROM '._PRE.'articles AS a
LEFT OUTER JOIN '._PRE.'categories as c
ON category = c.id
LEFT OUTER JOIN '._PRE.'categories as x
ON c.subcat =  x.id AND x.published ="YES"
WHERE position = 1
AND a.published = 1
AND c.published =\'YES\' '.$cat.'
ORDER BY date DESC
LIMIT '."$start, $size";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if ( $count ===0) {echo '<li>'.l('no_articles').'</li>';} else{
while ($r = mysql_fetch_array($result)) {
$date = date(s('date_format'), strtotime($r['date']));
$link = isset($r['xsef']) ? $r['xsef'].'/'.$r['csef'] : $r['csef'];
echo  '<li><a href="'._SITE.$link.'/'.$r['asef'].'/" title="('.$date.')">'.$r['title'].' ('.$r['name'].')</a></li>';
}}}

?>


In index.php , find

menu_articles(0,10);

You can add al list, comma delimited with the categories, you want to show '1,2,6,'. Like:

menu_articles(0,10,'1,2,6,');

The numbers (1,2,6 )  are the ids of the categories. To find an id of the category, go to the administration section of sNews, access the editpage of a category and look in the addressbar of the browser. There you will find the id

action=admin_category&id=1

Or, you can look straight into the database if you have phpMyAdmin
Logged

xper

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #5 on: July 13, 2008, 11:01:35 am »

Thank you very fast !

 but i get error

 in this line

Code: [Select]
if !empty($cat) $cat = 'AND category  in ('.$cat.') ';
Parse error: syntax error, unexpected '!', expecting '(' in

:)

 if i'm del    if !empty($cat) $cat = 'AND category  in ('.$cat.') ';

and add  <?php menu_articles(0,10,'2,3,'); ?> in index.php

i get Blank Page


« Last Edit: July 13, 2008, 11:07:12 am by xper »
Logged

Joost

  • Guest
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #6 on: July 13, 2008, 11:19:24 am »

Like I said: Untested.

Try
 if( !empty($cat)) $cat = 'AND category  in ('.$cat.') ';

And another typo I've made:

(0,10,'2,3,')

Don't end with the last comma.

<?php menu_articles(0,10,'2,3'); ?>
« Last Edit: July 13, 2008, 11:46:11 am by Joost »
Logged

xper

  • Newbie
  • *
  • Karma: 0
  • Posts: 5
Re: Get started at 1.7RC and i have some Q ab menu_articles
« Reply #7 on: July 13, 2008, 11:45:30 am »

very cool!

Thank you so much  ^^.  ;D
Logged