Help - Search - Members - Calendar
Full Version: MTOnThisDay
Movable Type Community Forum > Additional Resources > Plugin Development and Usage
Pages: 1, 2
nf0
Brad,
Looks like a really good job on this. But i'm having a problem,
I've used the exact code in the read me and the only thing that its posting are links to the current entries on my site. Any ideas?

Update: Totally my fault, its working Great!!
loopyca
Thank you thank you thank you!

You can see it in action over @ my site.

Thank you again!

Loopy biggrin.gif
rainwater
QUOTE
I've used the exact code in the read me and the only thing that its posting are links to the current entries on my site. Any ideas?

It sounds like you don't have the plugin installed correctly.  Take a look at your source from the output.  Do you see the tags?
loopyca
Actually - I spoke too soon.

I just added a new entry and now the 'On this Day' script is giving me back the following days (supposed to be July 4th in any year):

july 4, 2001 (this one is okay)
nov 21, 2000
january 3, 2000
july 11, 1998

The code that I am using is the following:
CODE
<MTOnThisDay>
   <div align="left"><MTEntries>
     <MTDateHeader>
       <a href="<$MTEntryLink$>">...
         <$MTEntryDate format="%Y"$>: <$MTEntryTitle$></a><br />
     </MTDateHeader>
   </MTEntries></div>
 </MTOnThisDay>


Also - it is including the current year's entries - me no want... can you have it exclude the current year?

Any ideas on why this is happening?! [You can check it out here: http://www.loopy.ca/onthisday.html (I've taken if off my main site until it is working properly)]

Loopy
bschoate
I've created a Movable Type 2.2 plugin that implements an "MTOnThisDay" container tag for Movable Type.

Here's an example of how it works:
CODE
<MTOnThisDay>
 <MTEntries>
   <MTDateHeader>
     <a href="<$MTEntryLink archive_type="Daily"$>">
       <$MTEntryDate format="%Y"$>
     </a>
   </MTDateHeader>
 </MTEntries>
</MTOnThisDay>


The above will list all the years that have blogs on the current month and day. It will link the year to the daily archive page.

You can use the tag on your main index (where it will drive off the current date/time whenever published) and you can also use it on your individual archive template where it will pull any blogs that match the month and day of the entry being published.

If you have questions or comments about this, please post them within this thread.

To download, use this link:
mtonthisday-1_1.zip

More information and installation instructions can be found inside the above zip file.

Update: July 5-- 1.1 release. Fixes DBM support, dates are now offset to match your blog's time offset as they should be and output now excludes the current year (or the year of the entry if you use the tag on an individual entry template).
girlie
Did this ever get resolved? I don't want to redo all my individual archives yet just to find out it won't give me the right results.
bschoate
If you read the first post for the topic (which I've edited to note the 1.1 updates) it mentions that the 1.1 release fixes the various problems loopyca was having.

If you're concerned about using the plugin, I recommend creating a test blog with a few entries, chaning their 'authored' date so that they cover multiple years so you can observe it's behavior and see if it produces the desired result.
girlie
Oh sorry - it's just confusing when the original post gets edited repeatedly instead of a new reply being added - though I somewhat understand why you're doing it that way.

And I guess reading it now, I'm still unclear that the new version addressed loopyca's different dates problem - is that the time offset issue you were referring to??
bschoate
QUOTE
output now excludes the current year


Which means that if you have entries on 2002, 2001 and 2000, the archive entry for 2002 will only link to 2001 and 2000. The archive entry for 2001 will only link to 2002 and 2000. And the archive entry for 2000 will only link to 2002 and 2001.

As for the odd dates that loopyca reported being returned, that was a compatability problem with the Berkeley DB file driver-- the 1.1 update corrects for that as well.
loopyca
Yes - as Brad said, it is all working wonderfully now. Although I must admit I have taken the code off of my individual entries as the rebuild times were hugely-affected (and I totally understand why, btw! smile.gif so for now it is only located in my sidebar on my main index.

But how awesome is Brad for doing this?!

Loopy
bschoate
Thanks loopy...

As for the performance issue, yes-- if you use this plugin on your INDIVIDUAL archive template, it will increase the rebuild time for the individual archives. No way around that.

Each time it's used it does an extra 'entries' lookup for entries from prior years. It does try to be smart about it, but is less efficient using the Berkeley DB files than mysql (Ben is looking into this-- MT's Berkeley DB driver seems to be pulling more entries than it needs to where the mysql driver works perfectly).

So, unless you're not rebuilding your entire site all the time, the extra delay should not be all that noticeable.
girlie
That's good to know (because, yes, it was meant to be for my individual archives). But I rarely rebuild them all - except that if I do put this plugin to work, I will need to rebuild them all then! That won't necessarily be a problem, because I will go through them individually anyway to provide excerpts for displaying in my retrospective section, thus rebuilding each one as I save them.

I'm really excited about this plugin, because I've been wanting to eliminate my manual method of doing this so I can make use of comments on my journal.

I do have another question (which I hope I haven't just overlooked the answer to here): What happens if you have no other entries on that date in history?
loopyca
If you have no entries - nothing shows up... yay, eh?!

Loopy
loopyca
Hey - Brad...

I just upgraded to MySql (yay!) but now the On This Day script is returning weird results (i.e. WRONG results). Any ideas? The code I have in my sidebar is the following:

CODE
<MTOnThisDay><MTEntries><b>on this day in...</b>
   <div align="center">
     <MTDateHeader>
       <a href="<$MTEntryLink$>"  "if(this.blur)this.blur()">...
         <$MTEntryDate format="%Y"$>: <$MTEntryTitle$></a><br />
     </MTDateHeader>
   </div>
 </MTEntries></MTOnThisDay>


Actually... it isn't being "wrong" per se... it IS returning results for July 24th (today) but the 'current post date' is July 21st - thus it looks odd.

No?!

Loopy
bschoate
Actually, it's behaving exactly as advertised:
QUOTE
You can use the tag on your main index (where it will drive off the current date/time whenever published) and you can also use it on your individual archive template where it will pull any blogs that match the month and day of the entry being published.


When you use the MTOnThisDay tag outside of an entry, it will use the server's date/time as the basis for doing it's lookup.
einarorn
I get a similar problem as the one Nf0 was having, that is it only shows links to the posts on my front page.  I used the following code

CODE
 <MTOnThisDay>
   <MTEntries>
     <MTDateHeader>
       <a href="<$MTEntryLink archive_type="Daily"$>">
         <$MTEntryDate format="%Y"$>
       </a>
     </MTDateHeader>
   </MTEntries>
 </MTOnThisDay>


You can see the output here (on the right under the calendar.
bschoate
You appear to be running Movable Type on a Windows platform. Please see this thread for information about setting the 'PluginPath' setting in your mt.cfg file. That should fix your plugins.

As it is, the OnThisDay plugin isn't functioning properly, so what you're seeing is the native behavior of the <MTEntries> tag.
einarorn
Thanks a lot, that worked! biggrin.gif
manky
huh.gif um …
this page
shows two links for the same year (there are two entries that day …) shouldn’t it be one link? to the page of that day?
sad.gif
ronincyberpunk
Just as a note, the new MTElse is very useful in conjunction with this plugin. I used it to make a text appear if I don't have any entries in the past days.
CODE
<MTOnThisDay>
...
</MTOnThisDay>
<MTElse>
Whoops. No entries on this day. I must have been slacking
</MTElse>


Patrick
http://www.ronincyberpunk.com/
bschoate
I'm a little confused as to why that should work ronincyberpunk... MTElse is for conditional tags only. MTOnThisDay is a plain container tag. What MT tag contains the MTElse tag that is making it work?
markpasc
I'm trying to use OnThisDay to display a random item from a year ago. Right now I'm using MTPerlScript and MTIfVar, to pick a random item and then only display the entry content if the ID matches:

CODE
<!-- entry from a year ago -->
<MTPerlScript>
my @items = (<MTOnThisDay><MTEntries>'<$MTEntryID$>', </MTEntries></MTOnThisDay>);
my $id = $items[int(rand(scalar(@items)))];
my $ret = <<EOF;
<TMOnThisDay><TMEntries>
<TMSetVarBlock name="OnThisDayItemID"><TMEntryID></TMSetVarBlock>
<TMIfVar name="OnThisDayItemID" value="$id"><div class='onThisDay'><TMInclude module="Entry"></div></TMIfVar>
</TMEntries></TMOnThisDay>
EOF
$ret =~ s/TM/MT/g;
print $ret;
</MTPerlScript>


but because the random item may not be the first in the MTEntries, sometimes it doesn't display the date header (in the Entry template module). Is there a more obvious way to get a random item that I overlooked, or should I just add a variable that forces the day to be displayed?
markpasc
I just made the Entry module display the date header if OnThisDayItem is set (with an MTIfVar). I had to go back and clear OnThisDayItem after the bit in my last comment, or all the comments on the rest of the page always had date headers too.
markpasc
I ended up writing my own plugin, MTRandomOTDEntry, to do what the code I posted above does.
kymberlie
So, is there a way to make MTOnThisDay display something if nothing was posted that day or do you have to change to a different plug-in?  I'm afraid I'm confused.   huh.gif
dysis
I keep getting this error:

QUOTE
Build error in template 'Footer': Error in tag: You used an MTEntryDate tag without a date context set up.


when I try to rebuild my footer.php, which has the code in it. The code I am using is below.

CODE
<div class="sidetitle">Previously on <$MTEntryDate format="%b %e"$>"></div>
<div class="sidetext"><MTIfEmpty expr="[MTOnThisDay]1[/MTOnThisDay]"><center>[i]There are no entries for this day.[/i]</center>
</MTIfEmpty><MTOnThisDay><MTEntries>
<MTDateHeader><a href="<$MTEntryLink archive_type="Daily"$>">[b]<$MTEntryDate format="%Y"$>[/b]:</a>
</MTDateHeader>
<$MTEntryExcerpt$></MTEntries></MTOnThisDay>
</div>


Any ideas why it is doing this? I didn't have an entry for that day before and so I made a dummy entry just to test it and it still didn't work. Please help. Thank you!
kadyellebee
Since you have a MTEntryDate tag in there, the module needs to be included into somewhere that is inside of an MTEntries context. Or in an individual Archive template.  
But since the date of rebuild shoule always be the same as MTDate, you can use that code for your "previous on.." instead. smile.gif

Kristine
dysis
Thank you very much. That worked.

biggrin.gif  :D  :D  :D  :D  :D  :D
kadyellebee
Excellent!  Glad that worked out smile.gif

Kristine
elvissinatra
Is there a way to get this plugin to return all entries plus or minus a few days?  That would be cool for sites that only publish a few items per week...
spackletoe
Hmm... I got this thing working, I love it, but I seem to have to rebuild in order for it to update, it doesn't update automatically.  How can I fix this?

Thanks,

-spack

http://www.joepopp.com
kadyellebee
All plugins are static, that is they only change upon rebuild.  If you want it to change on rebuild, you need a dynamic option, like PHP and/or PHP and MySQL smile.gif

Kristine
spackletoe
Hmm..  I'm using both PHP and MySQL.... So I need to include that script via an includes command?  Will that make it dynamic?
kadyellebee
No, you'll have to have a script that has been written in PHP to connect to the database.  I don't think I've seen one for this particular plugin, but if you are familiar with PHP, you could write one! smile.gif

Kristine
spackletoe
Wait, so everyone taht has this plugin manually rebuilds the index that it resides in each day?
kadyellebee
Well, the users I know who are using it post more than one weblog entry every day, so that's not a problem for them.  You could set up a cron job on your server to make it automatically rebuild at a certain time -- I believe that the RSS-Feed plugin has a script to help accomplish this.

Kristine
elvissinatra
Here's some php that will dynamically link to individual archives of entries created on that day. The formatting would have to be modified if you have more than one entry per day, but I thought I'd throw it out there to get things started.

CODE
<?php
 if (! @mysql_connect ("localhost", "LOGIN", "PASSWORD")) {
  exit();
 }
 if (! @mysql_select_db("DATABASE")) {
  exit();
 }
 $sql="SELECT entry_id, entry_title, entry_created_on, year(entry_created_on) AS entry_year FROM mt_entry WHERE month(entry_created_on) = month(CURRENT_DATE) and dayofmonth(entry_created_on) = dayofmonth(CURRENT_DATE) and year(entry_created_on) <> year(CURRENT_DATE) and entry_blog_id=1 ORDER BY entry_created_on desc";
 $result=mysql_query($sql);
 if (!$result) {
  echo ("<p>Error performing query: ".mysql_error()."</p>");
  exit();
 }
 while ($row = mysql_fetch_array($result)){
  echo("<div class='sidetitle'><b>".$row["entry_year"]."</b></div>\n");
  $archive="/arch/".str_pad($row["entry_id"],6,"0",STR_PAD_LEFT).".php";
  echo("<div class='side'><a href='".$archive."'>".$row["entry_title"]."</a></div>\n");
 }
?>


Of course, you'll have to change the LOGIN, PASSWORD, and DATABASE.  You'll have to also change the archive path (the line that starts with "$archive=").
L7 Productions
For some reason I'm only getting entries from March to come up after everyday entries. Check it out.
L7 Productions
I've singled out the code which you can see here.

For all of my plugins, the closing tag shows up upon rebuild, so I'm wondering if the problem has to do with my plugins folder or the mt.cfg file. The current PluginPath is set at:

CODE
PluginPath http://www.l7productions.com/fm/cgi-bin/plugins/


Anytime I delete that from the cfg file, I get a 400 Internal Error on all of my internal MT pages (cgi files). When I delete the plugins folder or set the PluginPath to the destination above, it works.

I tried going through setting up the load.pl plugin, but I get no results. You can see it here. I had it working yesterday, but now it doesn't want to work. Help!
kadyellebee
I'm confused.  I don't see any reference to adding a plugin path in the configuration settings.  

I looked up what a 400 error was, and it says that its normally caused by a syntax error in the URL.  You might see what your server log files say about this, as this isn't a normal error number that we see here.

Kristine
L7 Productions
Seems like the Blogtimes plugin was messing things up. I took the PluginPath out of the mt.cfg file and deleted the Blogtimes plugin from the plugin folder and rebuilt everything. It seems to be working now.

Update: Yep, that is definately the problem. I reinstalled the plugin, and the 400 Internal Error came up again. Does anyone know what may be causing this?

Oh, did we ever figure out how to get alternate text to display when there are no entries for that day a year ago?
garglebutt
I'm trying to use this to list birthdays to no avail:

CODE
<MTCalendar>
<MTOnThisDay>
<MTEntries category="Birthdays">
<MTDateHeader>
<a href="<$MTEntryPermalink$>"><$MTCalendarDay$>: <$MTEntryTitle$></a></br>
</MTDateHeader>
</MTEntries>
</MTOnThisDay>
</MTCalendar>


As far as I can tell this should go through each day of the current month and show all the entries that occured on the day of the year.

It currently produces no output at all. sad.gif
magnus13
freaking cool plugin. i love it.

here's a development request:

i don't know whether this is even remotely possible, but is there a way to set this up so that it'll show entries from the same day in previous years from other blogs? I don't mean other people's blogs - I mean other blogs under the same MT installation.

The reason is that I'm in the process of dividing my entries (which go back to 1999) into separate blogs for each year or so (because my host flips out when I rebuild too much stuff at once). It would be great to be able to show the same days in those separate blogs, too.
wibbler
I have configured this in the form "On This Day in 2002" for example. I have my results displayed in a line (no line breaks). This is fine when there's only one entry, but when there's two, the sentences run into each other (eg "On This Day in 2002 On This Day in 2001"). Is there a way to add an "if clause or similar, so that if there's two it inserts a comma between them?
kadyellebee
There may be another way to do it, but the Glue plugin pops into my mind first... smile.gif

Kristine
kayseebay
I am using this Plugin and It works great.

But I've got some other things I want to know about.

What I would like to do know is add something that will show up if there ISN'T an entry on that date - something along the lines of "apparently I wasn't very bloggy on this day" or something.

any one have any ideas on how to do this?

Also, I've set this plug in in an include so that it can show on my main site - it will be pulling entries from an archive site. If the page that include is on is rebuilt, will the include be rebuilt as well?

TIA
Ruthie
kayseebay
*bump*
jay-roh
Hi Brad (and everyone else) -

Just installed your plugin and for the the most part it's just great - however, one thing that (either I'm not doing right or) isn't working is the target link for each entry it links to.

for example - on my blog, the file that it's linking to is 2003_01_23.html - but the file that it should be linking to is 000685.html.

I'm using MT version 2.65 - is this a result of descrepencies between older and newer versions of MT?

anyways - thanks your your work!
kayseebay
it links to entry by date - the daily archive, not an individual entry.

Ruthie
jay-roh
QUOTE (kayseebay @ Jan 23 2004, 03:31 PM)
it links to entry by date - the daily archive, not an individual entry. 

Ruthie


ooooooooooooooops ... that's definitely my bad. I added that option to the archiving in MT and it worked. THANKS!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.