View previous topic :: View next topic |
Author |
Message |
ladytao
Joined: 19 Oct 2002 Posts: 28 Location: Alabama
|
Posted: Sun Nov 10, 2002 2:35 am Post subject: Archives in a drop-down menu? |
|
|
Is it possible to make my archives a drop-down menu? I have so many months listed, and hate to see them take up so much space.
Thanks. |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Sun Nov 10, 2002 12:38 pm Post subject: |
|
|
i did it on my site
www.gamerz.per.sg --> scroll to the bottom, if u want i can give u the code, it requires modifying b2arcvives.php _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
ladytao
Joined: 19 Oct 2002 Posts: 28 Location: Alabama
|
Posted: Sun Nov 10, 2002 3:27 pm Post subject: Cool! |
|
|
Yours looks great, and a lot more options too! How much modifying of the b2archives? I'm game to try anything (with a saved copy of course just in case..LOL)
Thanks.
Pam |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Sun Nov 10, 2002 3:30 pm Post subject: Re: Cool! |
|
|
ladytao wrote: | Yours looks great, and a lot more options too! How much modifying of the b2archives? I'm game to try anything (with a saved copy of course just in case..LOL)
Thanks.
Pam | erm, u need to hv the javascript and slight modification or b2archives.php, i post up the code tomorrow. _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Mon Nov 11, 2002 6:23 am Post subject: |
|
|
Put this javascript code in the page where you want to use the dropdown
Code: |
<script lanaguage="Javascript">
function jumpblogsarchive(form){
var selected=form.blogarchive.selectedIndex
if(form.blogarchive.options[selected].value=="None"){}
else{
parent.location.href=(form.blogarchive.options[selected].value);
}
}
</script>
|
Put this html also in the page where u want to have the dropdown menu
Code: |
<form method="POST">
<select name="blogarchive" size="1" onchange="jumpblogsarchive(this.form)">
<option value="None">Archives</option>
<option value="None"></option>
<? include "b2archives.php"; ?>
</select>
</form>
|
Modify b2archives.php to the mode == montly
[php:1:e61fab83c9]
<?php
function count_month_posts($year, $month) {
global $tableposts;
$count = mysql_query("SELECT COUNT(*) FROM $tableposts WHERE (YEAR(post_date) = '$year' AND MONTH(post_date) = '$month')");
$count = mysql_result($count,0);
return $count;
}
// *** b2 Archive file
require_once('./b2config.php');
require_once($b2inc.'/b2functions.php');
dbconnect();
// this is what will separate your archive links
$archive_line_separator = '<br />';
// this is what will separate dates on weekly archive links
$archive_week_separator = ' - ';
// archive link url
$archive_link_m = $siteurl.'/'.$blogfilename.$querystring_start.'m'.$querystring_equal; # monthly archive
$archive_link_w = $siteurl.'/'.$blogfilename.$querystring_start.'w'.$querystring_equal; # weekly archive
$archive_link_p = $siteurl.'/'.$blogfilename.$querystring_start.'p'.$querystring_equal; # post-by-post archive
// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
$archive_date_format_over_ride = 0;
// options for daily archive (only if you over-ride the general date format)
$archive_day_date_format = 'Y/m/d';
// options for weekly archive (only if you over-ride the general date format)
$archive_week_start_date_format = 'Y/m/d';
$archive_week_end_date_format = 'Y/m/d';
// --- //
$dateformat=get_settings('date_format');
$time_difference=get_settings('time_difference');
if (!$archive_date_format_over_ride) {
$archive_day_date_format = $dateformat;
$archive_week_start_date_format = $dateformat;
$archive_week_end_date_format = $dateformat;
}
if (basename($HTTP_SERVER_VARS['SCRIPT_FILENAME']) == 'b2archives.php')
include ('blog.header.php');
if (!isset($querycount)) {
$querycount = 0;
}
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
if ($archive_mode == 'monthly') {
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
$querycount++;
$arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
while($arc_row = mysql_fetch_array($arc_result)) {
$arc_year = $arc_row['YEAR(post_date)'];
$arc_month = $arc_row['MONTH(post_date)'];
$temp_count = count_month_posts($arc_year, $arc_month);
$monthyear = $arc_row["YEAR(post_date)"].zeroise($arc_month,2);
echo "<option value=\"$archive_link_m$arc_year".zeroise($arc_month,2)."\"";
if ($monthyear == $m)
echo ' selected="selected"';
echo ">- ";
echo $month[zeroise($arc_month,2)]." $arc_year";
echo ' ('.$temp_count.')';
echo "</option>\n";
}
} elseif ($archive_mode == 'daily') {
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
$querycount++;
$arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
while($arc_row = mysql_fetch_array($arc_result)) {
$arc_year = $arc_row['YEAR(post_date)'];
$arc_month = $arc_row['MONTH(post_date)'];
$arc_dayofmonth = $arc_row['DAYOFMONTH(post_date)'];
echo "<a href=\"$archive_link_m$arc_year".zeroise($arc_month,2).zeroise($arc_dayofmonth,2).'">';
echo mysql2date($archive_day_date_format, $arc_year.'-'.zeroise($arc_month,2).'-'.zeroise($arc_dayofmonth,2).' 00:00:00');
# echo $month[zeroise($arc_month,2)]." $arc_year";
echo '</a>';
echo $archive_line_separator."\n";
}
} elseif ($archive_mode == 'weekly') {
if (!isset($start_of_week)) {
$start_of_week = 1;
}
$arc_sql="SELECT DISTINCT YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date), WEEK(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC";
$querycount++;
$arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
$arc_w_last = '';
while($arc_row = mysql_fetch_array($arc_result)) {
$arc_year = $arc_row['YEAR(post_date)'];
$arc_w = $arc_row['WEEK(post_date)'];
if ($arc_w != $arc_w_last) {
$arc_w_last = $arc_w;
$arc_ymd = $arc_year.'-'.zeroise($arc_row['MONTH(post_date)'],2).'-' .zeroise($arc_row['DAYOFMONTH(post_date)'],2);
$arc_week = get_weekstartend($arc_ymd, $start_of_week);
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
echo "<a href=\"$siteurl/".$blogfilename."?m=$arc_year&w=$arc_w\">";
echo $arc_week_start.$archive_week_separator.$arc_week_end;
echo '</a>';
echo $archive_line_separator."\n";
}
}
} 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";
}
}
}
#echo $querycount."<br />\n";
#timer_stop(1, ;
?>
[/php:1:e61fab83c9] _________________
++ GamerZ.Per.Sg - Complex Simplicity
Last edited by GamerZ on Tue Nov 12, 2002 7:52 am; edited 2 times in total |
|
Back to top |
|
 |
ladytao
Joined: 19 Oct 2002 Posts: 28 Location: Alabama
|
Posted: Mon Nov 11, 2002 8:57 pm Post subject: Thanks! |
|
|
Thanks for the help!!
Pam |
|
Back to top |
|
 |
ladytao
Joined: 19 Oct 2002 Posts: 28 Location: Alabama
|
Posted: Mon Nov 11, 2002 9:15 pm Post subject: One more question... |
|
|
Everything works fine, except where it would show the # of posts for that month, the {} are empty.. any ideas?
Thanks! |
|
Back to top |
|
 |
pityme
Joined: 09 Nov 2002 Posts: 7
|
Posted: Mon Nov 11, 2002 9:37 pm Post subject: |
|
|
what is the code for the cat menu and the other drop menus on the site..please as id like to use them on my site too..if you feel like sharing.
thanks in advance . |
|
Back to top |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Tue Nov 12, 2002 12:47 am Post subject: |
|
|
There is already a function dropdown_cats() documented in the b2 readme.
you use it like this:
Code: | <form action="<?php echo $PHP_SELF ?>" method="get"><?php dropdown_cats(1) ?> <input type="submit" name="submit" value="Go" /></form> |
It doesn't use javascript, but then there is an argument that says triggering an action when a user makes a selection is a bad thing
Mike |
|
Back to top |
|
 |
pityme
Joined: 09 Nov 2002 Posts: 7
|
Posted: Tue Nov 12, 2002 2:15 am Post subject: |
|
|
hi and thanks mike..ill try this out..i was really looking to see the code that the gamerz site was using for its quick menu and cats section .. partly as a learning thing and partly because viewing the source it doesnt look like the function in b2.
. |
|
Back to top |
|
 |
ladytao
Joined: 19 Oct 2002 Posts: 28 Location: Alabama
|
Posted: Tue Nov 12, 2002 2:18 am Post subject: Re: One more question... |
|
|
ladytao wrote: | Everything works fine, except where it would show the # of posts for that month, the {} are empty.. any ideas?
Thanks! |
Anyone have any ideas? I'm lost here. (not new to me..ha ha) |
|
Back to top |
|
 |
Mister44

Joined: 31 Oct 2002 Posts: 237 Location: Philadelphia, PA, USA
|
|
Back to top |
|
 |
ladytao
Joined: 19 Oct 2002 Posts: 28 Location: Alabama
|
Posted: Tue Nov 12, 2002 4:14 am Post subject: Thanks for the info, |
|
|
I tried that earlier but never could get it to function right on mine. I've put mine back the way it was with the () where the post numbers should be.. and look into it a little more. I can live with it, even though I know there is probably some little something that needs tweaking.
Thanks again for pointing to that hack earlier.
Pam |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Tue Nov 12, 2002 6:01 am Post subject: |
|
|
pityme wrote: | what is the code for the cat menu and the other drop menus on the site..please as id like to use them on my site too..if you feel like sharing.
thanks in advance . | hmm, I do not mind sharing, what you would like to know? _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Tue Nov 12, 2002 7:54 am Post subject: Re: One more question... |
|
|
ladytao wrote: | Everything works fine, except where it would show the # of posts for that month, the {} are empty.. any ideas?
Thanks! | ops i forgot to att in Alex King Functions, i have edited the post, you can recopy the code eheh =)
Sorry _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
|