Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#31 2006-05-31 19:46:22

baby
Plugin Author
From: Buenos Aires, Argentina
Registered: 2005-10-16
Posts: 95
Website

Re: [archived] ob1_modified

Hi, obeewan…

I just installed ob1_modified (rel. 0.51) and I think I spotted a tiny glitch…

I’m using it in my default form like:

<pre>
Published: &lt;txp:posted /> by &lt;txp:author />
&lt;txp:ob1_modified output=“differs” starttext=”/ Last modified: “ />
&lt;txp:ob1_modified output=“differs” format=“author” starttext=” by “ />
</pre>

Which, supposedly outputs something like:

Published: May 25, 2006 by Mariano Absatz / Last modified: May 31, 2006 by Mariano Absatz

when used on a recently modified article and something like:

Published: May 25, 2006 by Mariano Absatz

when used on an article that was created and never modified.

However, the actual outcome of the latter is something like:

Published: May 25, 2006 by Mariano Absatz by 

Note the last by (actually surrounded by spaces).

After experimenting a bit and adding some debugging info to the $date_out variable, I noticed that, when you have $format=="author", $lastMod doesn’t get initialized and hence, $lastMod==$thisarticle["posted"] is false, so you don’t return "" early, the last lines get executed and you eventually return $date_out with $date_out==" by "

This can be solved if you initialize $lastmod before checking for $format=="author".

The following patch should solve this:

<pre>
—- ob1-modified-0.51.php 2006-05-31 16:17:12.895914863 -0300
+++ ob1-modified-0.51-baby.php 2006-05-31 16:16:29.558671887 -0300
-5,14 +5,14 if (is_array($atts)) extract($atts); $output = (empty($output)) ? ‘always’ : $output;

+ $lastMod = fetch(‘LastMod’,‘textpattern’,‘ID’,$thisarticle[‘thisid’]);
+ $lastMod = strtotime($lastMod); if($format==“author”){ if(empty($thisarticle[“author”])){ $lastModAuthor = fetch(‘LastModID’,‘textpattern’,‘ID’,$thisarticle[‘thisid’]); $date_out = fetch(‘RealName’,‘txp_users’,‘name’,$lastModAuthor); }else $date_out = $thisarticle[“author”]; }else{
- $lastMod = fetch(‘LastMod’,‘textpattern’,‘ID’,$thisarticle[‘thisid’]);
- $lastMod = strtotime($lastMod); $date_offset = $lastMod;

if(!empty($format)) { </pre>

at least, it worked for me.

HTH

UPDATE: In case you are not inclined to patch & compile, I generated this file for download: ob1-modified-0.51-baby.txt. You can download it, copy and paste it in your admin => plugin window.

It is the 0.51 version with this patch applied and the help text with a line pointing to this very thread in the changelog… As I didn’t find a license in obeewan’s site, I’m assuming it is either GPL or BSD and by publishing this here I hope I’m not violating either one. If this is not the case, please tell me so.

Last edited by baby (2006-07-14 19:45:30)


Mariano AbsatzEl Baby

I don’t suffer from insanity. I enjoy every minute of it.

Offline

#32 2007-09-03 00:53:08

obeewan
Archived Plugin Author
From: Stockholm, Sweden
Registered: 2004-08-12
Posts: 319
Website

Re: [archived] ob1_modified

Updated to work for TXP 4.x with no errors being produced.

And as always, bug reports are welcome.

See the first post of this thread for links.

Update

I will soon release a new version that uses joins on the database SELECT so instead of two queries beeing produced there will only be one (when writing this I got Highlander flashbacks :).

Last edited by obeewan (2007-09-13 05:42:31)


Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1

“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu

Offline

#33 2007-09-25 11:16:23

Anton
Plugin Author
From: Alingsås, Sweden
Registered: 2004-11-16
Posts: 138
Website

Re: [archived] ob1_modified

Is it just me or has 4.0.5 totally changed the way articles are dated? I mean, when clicking Write I now get a default date in the bottom right fields, the checkbox is not checked and thus every article I publish is “modified” already when going live for the first time.. (this explains what I thought was a bug with this plugin.)

Is there a way to get around this?

Offline

#34 2007-09-25 13:52:51

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: [archived] ob1_modified

Are you talking about how saving as a draft means it resets the posted date every time?
I’m not a big fan of that either..
‘Not familiar with a fix for that…


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#35 2007-09-30 12:34:53

obeewan
Archived Plugin Author
From: Stockholm, Sweden
Registered: 2004-08-12
Posts: 319
Website

Re: [archived] ob1_modified

You could hack the adminpart and make the “reset time to now” checkbox always selected. It doesn’t change the fact that the modified time will be now if you write older articles though.

If I think back, earlier in TXP it saved the modifed field as blank.


Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1

“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu

Offline

#36 2007-10-05 07:57:06

Anton
Plugin Author
From: Alingsås, Sweden
Registered: 2004-11-16
Posts: 138
Website

Re: [archived] ob1_modified

If you have hak_tinymce (or any other plugin with support for a javascript callback when creating new articles) this little snippet fixes this issue:

if($(‘input.publish[@name=“publish”]’)) $(‘#publish_now’).attr(‘checked’, true);

At least this is what fixed it for me.

cheers,

/Anton

Offline

#37 2007-10-05 22:31:01

obeewan
Archived Plugin Author
From: Stockholm, Sweden
Registered: 2004-08-12
Posts: 319
Website

Re: [archived] ob1_modified

Updated to v2.1, see first post for links.

v2.1 [2007-10-06]

Code

  • Re-wrote SQL to now get all the data in just one query (with joins)

Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1

“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu

Offline

#38 2007-10-06 09:25:46

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: [archived] ob1_modified

Henrik, in the 4.0.x branch (what is to become 4.0.6) $thisarticle[‘modified’] exists. Might save a query in your plugin.

Offline

#39 2007-10-06 12:58:29

obeewan
Archived Plugin Author
From: Stockholm, Sweden
Registered: 2004-08-12
Posts: 319
Website

Re: [archived] ob1_modified

Yeah. Anton gave me the heads up on that. But since I couldn’t wait until 4.0.6 was released I sent this one out pre-release.

When 4.0.6 is out that will remove one join in a future release of the plug in.


Plugins: ob1_advanced_search 1.032b, ob1_search_score 1.0, ob1_pagination 2.5, ob1_title 4.1, ob1_modified 2.1

“Let your plans be dark and as impenetratable as night, and when you move, fall like a thunderbolt.”
— Sun Tzu

Offline

#40 2008-03-27 20:10:43

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: [archived] ob1_modified

Is there a way to use this plugin outside of article context?

Using the tag in a page gives me an error.

Last edited by Ruhh (2008-03-27 20:11:09)


<txp:Ruhh />

Offline

Board footer

Powered by FluxBB