boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A GREAT Hack!... that doesnt exist...
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
Cyberian75



Joined: 26 Sep 2002
Posts: 1113
Location: Oregon

PostPosted: Fri Jan 31, 2003 1:14 am    Post subject: Reply with quote

That should be quite easy to implement. You just need to modify the SQL statements in b2archives.php file.

Bleh, I'm too lazy right now. Hehe... Razz
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Fri Jan 31, 2003 1:26 am    Post subject: Reply with quote

Blog17, try this:
Right at the end of b2archives.php
change the $archive_mode == 'postbypost' section from this
Code:

} elseif ($archive_mode == 'postbypost') {
    $requestarc = " SELECT ID,post_date,post_title FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
    $querycount++;
    $resultarc = mysql_query($requestarc);
    while($row=mysql_fetch_object($resultarc)) {
        if ($row->post_date != '0000-00-00 00:00:00') {
            echo "<a href=\"$archive_link_p".$row->ID.'">';
            $arc_title = stripslashes($row->post_title);
            if ($arc_title) {
                echo strip_tags($arc_title);
            } else {
                echo $row->ID;
            }
            echo '</a>';
            echo $archive_line_separator."\n";
        }
    }
}

to this
Code:

} elseif ($archive_mode == 'postbypost') {
    $requestarc = " SELECT ID, post_date, post_title, cat_name " .
                  " FROM $tableposts LEFT JOIN $tablecategories " .
                  " ON $tableposts.post_category = $tablecategories.cat_id" .
                  " WHERE post_date < '$now' AND post_category > 0" .
                  " ORDER BY post_date DESC";
    $querycount++;
    $resultarc = mysql_query($requestarc);
    while($row=mysql_fetch_object($resultarc)) {
        if ($row->post_date != '0000-00-00 00:00:00') {
            echo "<a href=\"$archive_link_p".$row->ID.'">';
            $arc_title = stripslashes($row->post_title);
            if ($arc_title) {
                echo strip_tags($arc_title);
            } else {
                echo $row->ID;
            }
            echo '</a>';
            echo " [$row->cat_name]";
            echo $archive_line_separator."\n";
        }
    }
}


Hope this helps,

Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Cyberian75



Joined: 26 Sep 2002
Posts: 1113
Location: Oregon

PostPosted: Fri Jan 31, 2003 1:30 am    Post subject: Reply with quote

Dang, Mike beat me to it. I was just about to post my modification.

Hey, I learned how to "spread out" the SQL statement from you.

Good job, Mike! Smile
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
blog17



Joined: 28 Jan 2003
Posts: 144
Location: London, UK

PostPosted: Fri Jan 31, 2003 4:12 am    Post subject: An ideas man... 8) Reply with quote

Hey, cool;

I just say it and you guys create it! Man... I gotta pickup on this PHP stuff, I got to day 7 on Sams PHP4 In 21 days...

anyway...

The code doesnt deal with >| " |< and >| ' |< .

For instance... Jus' Another Day -- come up as, Jus\' Another Day.

See?

The script wasnt exactly what I had in mind though -- I was thinking something like:

Quote:
[Category Title 1]
[Posting In Category]
[Posting In Category]
[Posting In Category]
[Posting In Category]

[Category Title 2]
[Posting In Category]
[Posting In Category]
[Posting In Category]
[Posting In Category]

[Category Title 3]
[Posting In Category]
[Posting In Category]
[Posting In Category]
[Posting In Category]


ok... I think you got the idea by Category Title 2 -- is this possible? I assume it will be difficult?
_________________
Check this out! The ULTIMATE site!
Back to top
View user's profile Send private message Visit poster's website
Cyberian75



Joined: 26 Sep 2002
Posts: 1113
Location: Oregon

PostPosted: Fri Jan 31, 2003 4:17 am    Post subject: Reply with quote

For your backslash problem, use a function called stripslashes.

And to group posts by categories, use the following:

Code:

} elseif ($archive_mode == 'postbypost') {
    $requestarc = " SELECT ID, post_date, post_title, cat_name " .
                  " FROM $tableposts LEFT JOIN $tablecategories " .
                  " ON $tableposts.post_category = $tablecategories.cat_id" .
                  " WHERE post_date < '$now' AND post_category > 0" .
                  " GROUP BY post_category " .
                  " ORDER BY post_date DESC";
    $querycount++;
    $resultarc = mysql_query($requestarc);
    while($row=mysql_fetch_object($resultarc)) {
        if ($row->post_date != '0000-00-00 00:00:00') {
            echo "[$row->cat_name]"."<br />\n";
            echo "<a href=\"$archive_link_p".$row->ID.'">';
            $arc_title = stripslashes($row->post_title);
            if ($arc_title) {
                echo strip_tags($arc_title);
            } else {
                echo $row->ID;
            }
            echo '</a>';
            echo $archive_line_separator."\n";
        }
    }
}



I didn't test this, so let me know. I bet the output would be weird.
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
blog17



Joined: 28 Jan 2003
Posts: 144
Location: London, UK

PostPosted: Fri Jan 31, 2003 5:06 am    Post subject: Reply with quote

Hey, thats great! 1 prob though... it only dislays the first article from the Category.

Code:
[Interesting Articles]
Was Michael Jackson Framed?
[In Seans Room]
No. 1
[General]
First blog!

_________________
Check this out! The ULTIMATE site!
Back to top
View user's profile Send private message Visit poster's website
Candle



Joined: 23 Dec 2002
Posts: 547

PostPosted: Fri Jan 31, 2003 5:26 am    Post subject: Here's something you might like. Reply with quote

Add links to your site .
http://www.blogrolling.com/
Site is looking good there blog17.
Back to top
View user's profile Send private message
macshack



Joined: 17 Jul 2002
Posts: 1204
Location: Phoenix, Az

PostPosted: Fri Jan 31, 2003 5:41 am    Post subject: Reply with quote

are u saying on the same line, beside the archive entry?

Make up a example of what your thinking post it.

michael e
Back to top
View user's profile Send private message Send e-mail
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Fri Jan 31, 2003 9:18 am    Post subject: Reply with quote

Blog17,
It sounds like you need something similar to Dodo's archive hack.
If you search on this forum you'll find it.
If you check here you can see my version in action. It has a form at the top to allow you to determine how you display them.
I think this coupled with a hack someone posted to limit the number of entries would, and with the form element removed would be just right.

I've got to go to work, but if someone hasn't already done it, I'll try to put sometihng to gether for you.

Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blog17



Joined: 28 Jan 2003
Posts: 144
Location: London, UK

PostPosted: Fri Jan 31, 2003 1:16 pm    Post subject: Reply with quote

mikelittle - Yeh, just like your site -- I want to group the postings by categories just like you have on your main page... is that hack on here? Ill look for it!

Candle -- thanx Smile

Edited: OK... I cant find the hack Sad Not that I noticed it on your site, I really want it!

Edited (again): Sorry... I meant the fullarchives.php page that you linked to there. Is there anyway to incorperate that into the index page?
_________________
Check this out! The ULTIMATE site!
Back to top
View user's profile Send private message Visit poster's website
Cyberian75



Joined: 26 Sep 2002
Posts: 1113
Location: Oregon

PostPosted: Fri Jan 31, 2003 6:01 pm    Post subject: Reply with quote

Blog17, try this...

Code:

} elseif ($archive_mode == 'postbypost') {
   $requestarc = " SELECT ID, post_date, post_title, cat_name " .
              " FROM $tableposts LEFT JOIN $tablecategories " .
              " ON post_category = cat_ID" .
              " WHERE post_date < '$now' AND post_category > 0 " .
              " GROUP BY post_category " .
              " ORDER BY post_date DESC";
   $querycount++;
   $resultarc = mysql_query($requestarc);
   while($row=mysql_fetch_object($resultarc)) {
      if ($row->post_date != '0000-00-00 00:00:00') {
         $cat_name = $row->cat_name;
         echo $cat_name."<br />\n";
         
         while ($cat_name == $row->cat_name) {
            echo "<a href=\"$archive_link_p".$row->ID.'">';
            $arc_title = stripslashes($row->post_title);
            if ($arc_title) {
               echo strip_tags($arc_title);
            } else {
               echo $row->ID;
            }
            echo '</a>';
            echo $archive_line_separator."\n";
         }
         
         echo "<br /><br />\n\n";
        }
    }


_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Sat Feb 01, 2003 1:26 am    Post subject: Reply with quote

Michael,
That doesn't work. You query results in one row for each post in a category, but it is the same row!
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Cyberian75



Joined: 26 Sep 2002
Posts: 1113
Location: Oregon

PostPosted: Sat Feb 01, 2003 1:29 am    Post subject: Reply with quote

Dang! Hahaha . . .
_________________
Michael P.
Back to top
View user's profile Send private message Visit poster's website AIM Address
mikelittle



Joined: 11 May 2002
Posts: 376
Location: UK

PostPosted: Sat Feb 01, 2003 1:43 am    Post subject: Reply with quote

blog17,

The original Dodo's archives hack is here, my version is below.

Code:
<?php
  //orignally by Dodo, http://pure-essence.net
  //http://tidakada.com/board/viewtopic.php?t=1136
  // Archives setup
  $b2varstoreset = array('order_by','asc_or_desc', 'year');
  for ($i=0; $i<count($b2varstoreset); $i += 1) {
    $b2var = $b2varstoreset[$i];
    if (!isset($$b2var)) {
      if (empty($HTTP_POST_VARS[$b2var])) {
        if (empty($HTTP_GET_VARS[$b2var])) {
          $$b2var = '';
        } else {
          $$b2var = $HTTP_GET_VARS[$b2var];
        }
      } else {
        $$b2var = $HTTP_POST_VARS[$b2var];
      }
    }
  }

  // over-ride general date format with MySQL format.

  // Date format from the DB
  // See http://www.mysql.com/doc/en/Date_and_time_functions.html for full spec
  $archive_date_format = '%d/%m/%Y';      // like 30/09/02
  //$archive_date_format = '%D %M %Y';      // like 30th September 2002
  //$archive_date_format = '%Y-%m-%d';      // like 2002-09-30
  //$archive_date_format = '%W, %D %M, %Y'; // like Monday, 30th September, 2002


  // display order choices
  $ORDER_BY_CAT   = 'cat_name';
  $ORDER_BY_DATE  = 'post_date';
  $ORDER_BY_ID    = 'ID';
  $ORDER_BY_TITLE = 'post_title';

  // What's the default list order?
  $defaultorderby = $ORDER_BY_CAT;
  // Default to ascending to descending?
  $defaultorder = "ASC";
  // What's the first year you started your b2?
  $first_year = "2002";

  $archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; // post-by-post archive
  $archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; // monthly archive

  // --- //

  $this_year = date("Y");

  if(!$order_by)
    $order_by = $defaultorderby;
  if(!$asc_or_desc)
    $asc_or_desc = "ASC";
  if(!$year) {
    $year = "All";
  }
?>
  <div class="content">
    <form  action="<?=$PHP_SELF?>" method="post">
      Sort by:
      <select class="form" name="order_by">
        <option value="<?=$ORDER_BY_ID?>" <?= ($order_by == $ORDER_BY_ID) ? ' selected' : "" ?>>id</option>
        <option value="<?=$ORDER_BY_DATE?>" <?=($order_by == $ORDER_BY_DATE) ? ' selected' : "" ?>>date</option>
        <option value="<?=$ORDER_BY_TITLE?>" <?=($order_by == $ORDER_BY_TITLE) ? ' selected' : "" ?>>title</option>
        <option value="<?=$ORDER_BY_CAT?>" <?=($order_by == $ORDER_BY_CAT) ? ' selected' : "" ?>>category</option>
      </select>
        direction:
      <select class="form" name="asc_or_desc">
        <option value="DESC" <?= ($asc_or_desc == "DESC") ? " selected" : "" ?>>descending</option>
        <option value="ASC" <?= ($asc_or_desc == "ASC") ? " selected" : "" ?>>ascending</option>
      </select>
        year:
      <select class="form" name="year">
        <option value="0">All years</option>";
<?php
  for ($i = $first_year; $i <= $this_year; $i++) {
    if ($year == $i)
      echo "        <option value=\"$i\" selected>$i</option>";
    else
      echo "        <option value=\"$i\">$i</option>";
  }
?>
      </select>
      <input type="submit" name="submit" value="sort" />
    </form>
<?php
  if ($year != 'All') {
    $year_clause = " WHERE YEAR(post_date) = $year";
  }
  $request = "SELECT $tableposts.*, DATE_FORMAT($tableposts.post_date, '$archive_date_format') AS formatted_date, " .
             " $tablecategories.cat_name as cat_name " .
             " FROM $tableposts LEFT JOIN $tablecategories ON $tableposts.post_category = $tablecategories.cat_ID " .
             $year_clause .
             " ORDER BY $order_by $asc_or_desc";
  $result = mysql_query($request) or die(mysql_error()."<br/>\n".$request);
  while($row=mysql_fetch_object($result)) {

    // are sorted by category?
    if ($order_by == $ORDER_BY_CAT) {
      $this_cat = $row->cat_name;
      if ($this_cat != $previous_cat) {
        echo "\n<br /><br /><h4>" . $row->cat_name;
        echo "</h4>\n";
      }
      $previous_cat = $this_cat;
    }
   
    $postdata = get_postdata2($row->ID);
    $thismonth = mysql2date("Y\-m", $postdata['Date']);
    $thisyear  = mysql2date("Y", $postdata['Date']);
    $linkmonth = mysql2date('Ym', $postdata['Date']);
    $i = '/'.$thismonth.'/';

    // only do monthly stuff if we're not doing category/title
    if (($order_by != $ORDER_BY_CAT) && ($order_by != $ORDER_BY_TITLE)) {
      if ($thismonth != $previousmonth) { // change month?
        if (preg_match($i,$postdata['Date'])) {
          echo "\n".'<br /><br /><h4><a href="'.$archive_link_m.$linkmonth;
          if ($querystring_separator == '/') {
              echo $querystring_separator.$month[substr($thismonth,5,2)].'-'.$thisyear;
          }
          echo '">';
          echo $month[substr($thismonth,5,2)].' '.$thisyear;
          echo '</a></h4>';
        }
      }
      $previousmonth = $thismonth;
    }
   
    echo $row->formatted_date;
    $title = $postdata['Title'];
    if ($title) {
        $title = stripslashes($title);
        $title2 = preg_replace('/[^a-zA-Z0-9\.-]/', '_', $title);
    }
    echo " - <a href=\"".$archive_link_p.$row->ID.$querystring_separator;
    if ($querystring_separator == '/') {
        echo $title2;
    }
    echo '">';
    if ($title) {
      echo $title;
    } else {
      echo $postdata['ID'];
    }
    echo "</a><br />\n";
  } // end while
?>
  </div> <!-- content -->



I actually store this in a file called archives-panel.php which is included by fullarchives.php which looks like this (I'll document my system soon):
[php:1:1cdadf4485]<?php
require_once('./b2config.php');
require_once($b2inc.'/b2functions.php');
include('blog.header.php');
$extra_title=" :: Full Archives";
include('htmlhead.php');
?>
<body>
<?php
include_once('pageheader.php');
include_once('searchcheck.php');
include_once('archives-panel.php');
include_once('leftcolumn.php');
include_once("rightcolumn.php");
?>
</body>
</html>
[/php:1:1cdadf4485]

So the database connection gets set up in blog.header.php

There is also another varient on Dodo's hack here


Hope this helps,
Mike
_________________
Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't."


Last edited by mikelittle on Sun Feb 02, 2003 1:35 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
blog17



Joined: 28 Jan 2003
Posts: 144
Location: London, UK

PostPosted: Sat Feb 01, 2003 3:58 pm    Post subject: Reply with quote

Um... what do I do with that code? You didnt say what file names to name them or anything. I tried Dodo's hack, but it doesnt list by category... and I tried the other varient, which also doesnt list by category. Also... none of them lists all the categories like yours does... with the postings below them:

[category name]

[posting]
[posting]
[posting]
[posting]

[category name 2]

[posting]
[posting]
[posting]
[posting]
_________________
Check this out! The ULTIMATE site!
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group