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: Page text-links listed by Category & Sub-Category with Article links  (Read 3910 times)

Rui Mendes

  • Development,Testing, Support
  • Hero Member
  • *****
  • Karma: 195
  • Posts: 1009
  • sNews1.7
    • Comunidade Portuguesa
Re: Page text-links listed by Category & Sub-Category with Article links
« Reply #15 on: January 21, 2011, 08:28:09 PM »

Hello stephane.
I rewrite the function Doug did, I don't know is that you want.

In function as no reference to id, so I create for the first
If you have category1, will create id="first_categegory"

Quote
<?php

// SITEMAP - shows links to pages & articles in categories & subcategories: position IN (1,3)
function sitemap() {
   echo '<h2>'.l('sitemap').'</h2>';
   echo '<p>';
   $link = '<a href="'._SITE;
   echo $link.'"><strong>'.l('home').'</strong></a> '.l('divider').' '; // Home is not really a page.
   echo $link.'archive/"><strong>'.l('archive').'</strong></a> '.l('divider').' '; // archive
   echo $link.'contact/"><strong>'.l('contact').'</strong></a>'; // contact
   echo '</p>';
   echo '<h3><strong>'.l('articles_pages').'</strong></h3>';
   echo '<ul>';
   $art_query = 'SELECT title, seftitle, date FROM '._PRE.'articles'.' WHERE position IN (1,3) AND published = 1 AND visible = \'YES\'';
   $cat_query = 'SELECT id, name, seftitle, description, subcat FROM '._PRE.'categories'.' WHERE published = \'YES\' AND subcat = 0 ORDER BY catorder,id';
   $cat_result = mysql_query($cat_query);
   if (mysql_num_rows($cat_result) == 0) {
       echo '<li>'.l('no_articles').'</li></ul>';
   } else { $i=0;
       while ($c = mysql_fetch_array($cat_result)) {
      $category_title = cleanSEF($c['seftitle']);
      $id_first = $i == 0 ? ' id="first_'.$category_title.'"' : ''; $i++;
      echo '<li><strong><a href="'._SITE.$category_title.'/" title="'.$c['description'].$id_first.'>
      '.$c['name'].'</a></strong>';
      $catid = $c['id'];
      $query = $art_query.' AND category = '.$catid.' ORDER BY id DESC';
      $result = mysql_query($query);
      if (mysql_num_rows($result) > 0) {
          echo '<ul>';
      }
      while ($r = mysql_fetch_array($result)) {
          echo '<li>'.l('divider').'  <a href="'._SITE.$category_title.'/'.$r['seftitle'].'/">'.$r['title'].'</a></li>';
      }
      if (mysql_num_rows($result) > 0) { echo '</ul>'; }
      $subcat_result = mysql_query('SELECT id, name, seftitle, description, subcat FROM '._PRE.'categories'.' WHERE published = \'YES\' AND subcat = '.$c['id'].' ORDER BY catorder ASC');
      if (mysql_num_rows($subcat_result) > 0) {
          echo '<ul>';
      } $j = 0;
      while ($s = mysql_fetch_array($subcat_result)) {
          $subcat_title = cleanSEF($s['seftitle']);
          $subcat_name = cleanSEF($s['name']);
         $sub_first = $j == 0 ? ' id="first_".$subcat_name : ''; $j++;
          echo '<li class="subcat"><strong><a href="'._SITE.$category_title.'/'.$subcat_title.'/" title="'.$s['description'].'"'.$sub_first.'>'.$subcat_name.'</a></strong>';
          $subcatid = $s['id'];
          $query = $art_query.' AND category = '.$subcatid.' ORDER BY id DESC';
          $artresult = mysql_query($query);
          if (mysql_num_rows($artresult) > 0) { echo '<ul>'; }
          while ($r = mysql_fetch_array($artresult)) {
         echo '<li class="subcat">'.l('divider').'<a href="'._SITE.$category_title.'/'.$subcat_title.'/'.$r['seftitle'].'/">'.$r['title'].'</a></li>';
                    }
          if (mysql_num_rows($artresult) > 0) { echo '</ul>'; }
          echo '</li>';
      }
      if (mysql_num_rows($subcat_result) > 0) { echo '</ul>'; }
      echo '</li>';
       }
       echo '</ul>';
   }
?>
« Last Edit: January 21, 2011, 08:32:21 PM by Rui Mendes »
Logged
Need a Job on Europe. Linkdin - Facebook / Group

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Page text-links listed by Category & Sub-Category with Article links
« Reply #16 on: January 21, 2011, 08:45:08 PM »

I haven't done any further work on this particular package since November 2009.
Unfortunately, I have not had time to work further on it since then either.

Please remember that everything offered on these forums by anyone is shared freely without any expression of warranty or any guarantee that it works perfectly and there is no obligation on the part of the author or originator to fix anything that might not be working perfectly. You take it as it is, and you are free to explore it and develop it further in any way you wish.

I should also note that the files in any download I share on these forums come with comments in them to help you locate all of the mod locations in the files, so anyone can explore, learn from, trouble-shoot and expand on what's provided.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

stephane

  • Full Member
  • ***
  • Karma: 6
  • Posts: 194
Re: Page text-links listed by Category & Sub-Category with Article links
« Reply #17 on: January 21, 2011, 09:07:15 PM »

@Rui
Thanks for you help on this. I was asking this for menu itself not specially for sitemap.
But don't worry I can live without any change on this Mod, is working great like this and xhtml validation can wait  ;)

@Keyrocks
Yes you are absolutely right. I just asked because I noticed this point (validation xhtml).
I saw and really appreciate the specific file that you wrote to explain this MOD, it's very useful even if I don't understand everything in php stuff  :P
It was not my idea to ask for warranty... I know and really appreciate your great job and help on sNews Mods.

Thanks again
Stéphane
Logged

Edgardo

  • Newbie
  • *
  • Karma: 1
  • Posts: 22
Re: Page text-links listed by Category & Sub-Category with Article links
« Reply #18 on: August 02, 2012, 02:04:34 AM »

hi, well Im trying your mod and its grate, olso have done some mod on it, just on image, for mixing whith text, some very simple thing but usefull for me, The thing was that text did not fit well so I added some atributes to img tag like align, with higt hspace border(becose hspace dont work well so added a border to img and should put color like bachground), anyway as sead it is not a big thing, and for shore is a better way, so if anyone knows just sed that, and if anone is intrested I will post it thenks again
Logged
Pages: 1 [2]