 |
 |
 |
 |
 |
| Author |
Message |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
New Archives (virtual) Feature |
|
Since cnr doesnt exactly have a real archive function but rather displays " month : (# of articles)" i thought of a different approach to this.
How about if we can give 3 drop down's to select the date and then display the posts from that given day. T
his is actually much more similar to calander function but i cudnt figure out head or tails of how to modify calandar.
Ok now i tried to do some coding but i aint no programmer so failed in it. This is what i tried.
1. First i created a form that includes the dropdowns and posts to a file called archive.php
 |  | <form id="frm_archive" name="frm_archive" method="post" action="archives.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><select name="day" class="archivedropdown" id="day">
<option value=""
selected="selected"> Date</option>
<option value="1">1</option>
<option
value="2">2</option>
<option value="3">3</option>
<option
value="4">4</option>
<option value="5">5</option>
<option
value="6">6</option>
<option value="7">7</option>
<option
value="8">8</option>
<option value="9">9</option>
<option
value="10">10</option>
<option value="11">11</option>
<option
value="12">12</option>
<option value="13">13</option>
<option
value="14">14</option>
<option value="15">15</option>
<option
value="16">16</option>
<option value="17">17</option>
<option
value="18">18</option>
<option value="19">19</option>
<option
value="20">20</option>
<option value="21">21</option>
<option
value="22">22</option>
<option value="23">23</option>
<option
value="24">24</option>
<option value="25">25</option>
<option
value="26">26</option>
<option value="27">27</option>
<option
value="28">28</option>
<option value="29">29</option>
<option
value="30">30</option>
<option value="31">31</option>
</select></td>
</tr>
<tr>
<td><select name="month" class="archivedropdown" id="month">
<option value=" "
selected="selected">Month</option>
<option
value="January">January</option>
<option
value="February">February</option>
<option
value="March">March</option>
<option
value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option
value="July">July</option>
<option
value="August">August</option>
<option
value="September">September</option>
<option
value="October">October</option>
<option
value="November">November</option>
<option
value="December">December</option>
</select></td>
</tr>
<tr>
<td><select name="year" class="archivedropdown" id="year">
<option selected="selected">Year</option>
<option value="2006">2006</option>
</select></td>
</tr>
<tr>
<td><input name="Go" type="submit" id="Go" value="GO" /></td>
</tr>
</table>
</form> |
2. Then i created a archives.php file that attempts to capture year, month and day and display the news of that day.
 |  | <?php
include 'news/head.php';
?>
$number = 7;
$template = "headlines"
include $cutepath.'/show_news.php'; |
3. The form coding was done assuming that it would be creating a link in the nature of
 |  | http://www.mydomain.com/archives.php?year=2006&month=10&day=18 |
I tried out manually typing the following link
 |  | http://www.mydomain.com/fullstory.php?year=2006&month=10&day=18 |
and it works perfectly. So i ws just trying create the same effect, but it didnt work.
Any help with this pls??
|
|
| Thu Oct 19, 2006 4:32 am |
|
 |
Guest
|
|
|
Please login to hide the ads.
|
|
|
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2635 Location: Germany |
|
|
|
You have to pass the months as numbers instead of names.
Change for example <option value="March">March</option> to <option value="3">March</option>.
Or you can use my version:
 |  | <?php
include 'head.php';
$sday[] = '';
$sday[0] = 'Date';
for ($i = 1; $i < 32; $i++){
$sday[$i] = $i;
}
$smonth[] = '';
$smonth[0] = 'Month';
$month_names = array("1" => "January", "2" => "February", "3" => "March", "4" => "April", "5" => "May", "6" => "June", "7" => "July", "8" => "August", "9" => "September", "10" => "October", "11" => "November", "12" => "December", );
for ($i = 1; $i < 13; $i++){
$smonth[$i] = $month_names[$i];
}
$syear[] = '';
$syear[0] = 'Year';
for ($i = 2005; $i < (date('Y') + 1); $i++){
$syear[$i] = $i;
}
?>
<form id="frm_archive" name="frm_archive" method="post" action="archives.php">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><?=makeDropDown($sday, 'day', 'Date'); ?></td>
</tr>
<tr>
<td><?=makeDropDown($smonth, 'month', 'Month'); ?></td>
</tr>
<tr>
<td><?=makeDropDown($syear, 'year" onChange="document.frm_archive.submit();', 'Year'); ?></td>
</tr>
<tr>
<td><input name="Go" type="submit" id="Go" value="GO" /></td>
</tr>
</table>
</form> |
You can remove the submit button. The form will automatically submit after selecting the year (javascript).
|
|
| Thu Oct 19, 2006 7:40 pm |
|
 |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
|
|
Jeez!! What a mutt i am How did i miss that!!
Its working perfectly now!! 
|
|
| Fri Oct 20, 2006 3:03 am |
|
 |
ksen

Joined: 04 Jun 2006 Posts: 142
|
|
|
|
hi fi-dd,
i just thought abt how we can optimize this scrpt a little.
And this just occured to me -- right now when we call the show_news.php script from the archives.php it goes thru the whole news base and captures the title and the short story and whatever other stuff into memory rite??
(If i'm not mistaken this must be happening in the search.php as well!! I dint have time to look at the strawberry search as u suggested,but i will..)
I'm sure this puts abit of effort on the server. Ok, to optimize this script can we capture only the titles of news items and show it on the page?? may be if we could have a separate small script like show_archives.php, so that the original show_news.php can b kept alone??
Just a thought 
|
|
| Sat Oct 21, 2006 9:31 am |
|
 |
sitehire
Joined: 27 Mar 2008 Posts: 7
|
|
|
|
This works great for me, which is strange, coz the actual archive system on cutenewsru doesnt.
However, instead of having a drop down, I'd like to show the results like...
April 2008
March 2008
February 2008
January 2008
December 2007
...for instance, just like on here
Can anyone help?
|
|
| Sun Apr 27, 2008 12:56 pm |
|
 |
FI-DD
Admin

Joined: 22 Sep 2005 Posts: 2635 Location: Germany |
|
|
|
 |  | coz the actual archive system on cutenewsru doesnt. |
Why not? What happens?
|
|
| Thu May 01, 2008 9:39 am |
|
 |
sitehire
Joined: 27 Mar 2008 Posts: 7
|
|
|
|
Well all the links (e.g. January 2008, February 2008) just link to the same page e.g. myurl.com/news.php, meaning when you click them, it just shows up every single news article within the system.
|
|
| Thu May 08, 2008 11:56 pm |
|
 |
|
|
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 You cannot attach files in this forum You can download files in this forum
|
|
 |
 |
 |
|