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.

Pages: 1 [2]

Author Topic: A unique SEF link to browse a cat and its subcats in the home pages?  (Read 3435 times)

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #15 on: April 14, 2010, 01:10:15 pm »

If your not going to use it till the end of the week, then let me fix it. I realized I made a *BIG* mistake.  You will get 404's on the subcat articles because the subcat sef isn't coming through. Like I said, let me fix it and report back.
« Last Edit: April 14, 2010, 01:23:34 pm by nukpana »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #16 on: April 14, 2010, 01:24:47 pm »

Okey... I'm confident: while I'll be working on the layout.

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #17 on: April 14, 2010, 01:29:47 pm »

Fix coming up....  The fix was in the following query, so I didn't have to do much.... sorry about that

1. Backup
2. Add new functions:
Code: [Select]
// REDID 4/23
function child_list( $catid ) {
static $list;
if (!$list) {
$list = array();
$query = 'SELECT id FROM '._PRE.'categories WHERE published = \'YES\' AND subcat = '.$catid;
$result = mysql_query($query);
while ($r = mysql_fetch_assoc($result)) {
$list[] = $r;
}
}
return $list;
}

// From http://us3.php.net/manual/en/function.implode.php#96100
function r_implode( $glue, $pieces ) {
   foreach( $pieces as $r_pieces ) {
     if( is_array( $r_pieces ) ) {
       $retVal[] = r_implode( $glue, $r_pieces );
     } else {
       $retVal[] = $r_pieces;
     }
   }
   return implode( $glue, $retVal );
}

3. In function articles, find the first two lines and change where it is noted:
Code: [Select]
// pagination
$currentPage = strpos($SEF, l('paginator')) === 0 ? str_replace(l('paginator'), '', $SEF) : '';
if ($_catID) {
// eq
//  REDID 4/23
$child_list = child_list( $_catID );
$subList = !empty($child_list) ? ',' . r_implode(',', $child_list) : '';
/*
$count = 'SELECT COUNT(a.id) AS num
FROM  '._PRE.'articles'.' AS a
WHERE position = 1
AND a.published =1
AND category = '.$_catID.$visible.'
GROUP BY category';
*/
$count = 'SELECT COUNT(a.id) AS num
FROM  '._PRE.'articles'.' AS a
WHERE position = 1
AND a.published =1
AND category IN ( '.$_catID . $subList.' )
'.$visible;
// end eq

} else {

4. Same thing as above:
Code: [Select]
// get the rows for category
if ($_catID) {
/*
$query_articles = 'SELECT
a.id AS aid,title,a.seftitle AS asef,text,a.date,
a.displaytitle,a.displayinfo,a.commentable,a.visible
FROM '._PRE.'articles'.' AS a
WHERE position = 1
AND a.published =1
AND category = '.$_catID.$visible.'
ORDER BY artorder ASC,date DESC
LIMIT '.($currentPage - 1) * $article_limit.','.$article_limit;
*/
//  ADDED 4/23
$child_list = child_list( $_catID );
$subList = !empty($child_list) ? ',' . r_implode(',', $child_list) : '';
$query_articles = 'SELECT
a.id AS aid,title,a.seftitle AS asef,text,a.date,
a.displaytitle,a.displayinfo,a.commentable,a.visible,
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 category IN ( '.$_catID . $subList.' )
'.$visible.'
AND c.published =\'YES\'
ORDER BY artorder ASC,date DESC
LIMIT '.($currentPage - 1) * $article_limit.','.$article_limit;

} else {
« Last Edit: April 23, 2010, 11:26:42 pm by nukpana »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #18 on: April 14, 2010, 04:31:50 pm »

I was away and will see tomorrow .
Thanks Jason.

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #19 on: April 15, 2010, 11:52:50 am »

That's awesome!!!
Man you're so talented: I just tested it locally and it makes it.

Some snoozers might be interested so it should be modded " Dudes...
"as it is" don't you think? but,

there might be an improvment:
the one wich enable to chose how many articles to be displayed in the pagination pages.

Karma for Jason and if you have to promote yourself via my blog just PM me.
Thanks a lot pal. I really appreciate your kindness.


nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #20 on: April 16, 2010, 01:10:06 pm »

NP and thanks for the kind words.  If you want, you can post the mod, or I will take a peek in a day or so and post it.
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #21 on: April 16, 2010, 01:26:57 pm »

I will as soon as my on-line demo will be ready...

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #22 on: April 23, 2010, 01:37:27 pm »

Demo is ready now.
See HTML5 gallery

There's however an issue... Jason:
On the category home page either if I ask for a break (the read-on link) or if I click on the title's link the sub-cat isn't printed in the link so it goes 404.
Did I, did we forgot something? ???
« Last Edit: April 23, 2010, 03:06:24 pm by Sven »
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #23 on: April 23, 2010, 08:24:12 pm »

I don't see the link that gives the error. In any case the solution builds from the regualr center function - does the regular read more link work (dumb question)?

Ok now I see it.  Ok hold on, let me see what is going on....

EDIT - try the instructions above now..... I changed some things (hacked) so it should work without pagination. I can't reproduce what you are getting (no subcat), so you need to retry it out (on a fresh install)
« Last Edit: April 23, 2010, 11:30:15 pm by nukpana »
Logged

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: A unique SEF link to browse a cat and its subcats in the home pages?
« Reply #24 on: April 24, 2010, 08:40:12 am »

Seems Okey now Jason.

When I'm back (I'm leaving today home for a little week) I publish the Mod as promised.
Take care pal. And thanks again. 8)
Pages: 1 [2]