Comment search

Creating and modifying plugins.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Comment search

Post by yellowled »

A user asked me to implement support for comment search in 2k11. "Great, it's got a tpl file.", I thought. However, it seems I can not use my @serendipity_smarty_html5time modifier which I create in config.inc.php:

Code: Select all

function serendipity_smarty_html5time($timestamp) { return date("c", $timestamp); }
$serendipity['smarty']->register_modifier('serendipity_smarty_html5time', 'serendipity_smarty_html5time');
Using this in the plugin's tpl file breaks, well, everything. entries.tpl reports "No entries to print", comment search doesn't find anything. I positively tracked this back to my custom modifier.

Any ideas?

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Comment search

Post by garvinhicking »

Hi!

What does the .tpl look like? Are you sure the only thing you change is removing a "|@serendipity_smarty_html5time" and nothing else?

I don't see how this should affect things. You're testing on s9y 1.7 I guess? Do you have a chance to test it in a 1.6 (Smarty2) environment? This would allow to check whether Smarty3 is the cause of this (in which case I would need Ians Help :))

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Comment search

Post by Timbalu »

<ironic.mode.on>
Stop blaming Smarty3, Garvin! I must really wonder... you don't seem to like it very much.... :shock:
</i.m.end>

I also can't really see how this should effect things..., but YL, do you remember the thread where I only was able to use 2k11 as default, when that modifier fnc moved to core? I am not sure if that might be the case with your issue and can't really remember why this was the only way to get this to work....

So Garvins suggestion testing with 1.6 is good. Afterwards you might try and use

A. remove the array modifier @

Code: Select all

|serendipity_smarty_html5time
B. change name - functionname or v.v.

Code: Select all

$serendipity['smarty']->register_modifier('s9y_smarty_html5time', 'serendipity_smarty_html5time');
C. use smarty3 syntax testwise

Code: Select all

$serendipity['smarty']->registerPlugin('modifier', 's9y_smarty_html5time', 'serendipity_smarty_html5time');
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

garvinhicking wrote:Are you sure the only thing you change is removing a "|@serendipity_smarty_html5time" and nothing else?
Pretty much, yes. I don't have the .tpl file on this machine right now, but I did test about everything, and this is the only thing producing this behaviour.
garvinhicking wrote:You're testing on s9y 1.7 I guess?
1.6, actually. :)

I'm in the process of setting up the dev blog on my second machine. Will report back with further test results.

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Comment search

Post by garvinhicking »

Hi!
Timbalu wrote:<ironic.mode.on>
Stop blaming Smarty3, Garvin! I must really wonder... you don't seem to like it very much.... :shock:
</i.m.end>
I'm only sick and tired of how much work it requires us to adapt to Smarty3 when we don't get anything feasible in return. I for one don't feel any speed increase. But that's a different matter, using recent versions of software is always better. I only wish it weren't causing so much pain.

No offense intended though, neither on you nor the smarty devs. Since YL writes that 1.6 is causing the same behavoir, this strikes me as odd.

The config.inc.php of a template is loaded in serendipity_smarty_init(), and the plugin executes its code later on. So all modifiers should exist there.

YL: *OTHER* involved plugins could be the cause. You might want to test this on an installation without other possibly influencing plugins that use Smarty; some plugins call serendipity_smarty_init() on their own (freetag, AFAIR, and maybe also staticpage). Those could interfer for disregarding the config.inc.php modifiers.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

garvinhicking wrote:Since YL writes that 1.6 is causing the same behavoir, this strikes me as odd.

The config.inc.php of a template is loaded in serendipity_smarty_init(), and the plugin executes its code later on. So all modifiers should exist there.
Turns out the commentsearch plugin does some odd things in general like concatenate included avatars etc. (Grischa's working on that already.)

I will test this more thoroughly later, but at the moment, I'm working on other stuff concerning the server itself. Once this is resolved, I will test this issue and report back. :)

YL
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Comment search

Post by Timbalu »

Take a Peter Stuyvesant, Garvin! :D ...did not read my i-tags?

S3-Speed increase? Its OOP, a huge blowup in workspace! But they did a incredible good work making this fast! YL already stated the Backend being faster than ever... ;-)
And we get a lot for it. Change always is painful on the one side... :)

About serendipity_smarty_init() - oh yes - I remember - as I once knocked-out comment or contactform with this...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
blog.brockha.us
Regular
Posts: 695
Joined: Tue Jul 03, 2007 3:34 am
Location: Berlin, Germany
Contact:

Re: Comment search

Post by blog.brockha.us »

I updated commentsearch in Spartacus now.

The problem was: It is calling frontend_display, what let all other plugins create some extra HTML into the comment. The template did fetch this comment and truncated it. This will of course produce invalid output, because it doesn't strip tags before and will truncate in the middle of tags, if tags are delivered by other plugins.

I changed it in that way, that result.comment will be handed without tags to the template, so the template can truncate freely. I added result.commenthtml in order to have the chance to handle full blown up html comments in your own template, if you like.
- Grischa Brockhaus - http://blog.brockha.us
- Want to make me happy? http://wishes.brockha.us/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

Timbalu wrote:YL already stated the Backend being faster than ever... ;-)
Could've been just my subjective impression, you know? AFAIR no one actually confirmed that.

YL
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Comment search

Post by Timbalu »

Nevertheless it would be good to find the issue itself...,

we could try and include a:

Code: Select all

        if (!is_object($serendipity['smarty'])) { 
            serendipity_smarty_init();
        }
just right before registering that modifier in 2k11's config, couldn't we?

@YL, but that counts.... ;-)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

Timbalu wrote:

Code: Select all

        if (!is_object($serendipity['smarty'])) { 
            serendipity_smarty_init();
        }
Doesn't change anything.

Still using the same version of commentsearch since my dev blog pulls updates via Spartacus, so Grischa's commit isn't there yet.

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

Timbalu wrote:A. remove the array modifier @

Code: Select all

|serendipity_smarty_html5time
B. change name - functionname or v.v.

Code: Select all

$serendipity['smarty']->register_modifier('s9y_smarty_html5time', 'serendipity_smarty_html5time');
C. use smarty3 syntax testwise

Code: Select all

$serendipity['smarty']->registerPlugin('modifier', 's9y_smarty_html5time', 'serendipity_smarty_html5time');
A. doesn't put the actual time in the datetime attribute:

Code: Select all

<time datetime="Serendipity_smarty_html5time">25.11.2011</time>
B. gives me an error 500 (I did not change the actual function's name, I just modified the line you quoted.)

C. Why should I use Smarty3 in a 1.6 blog?

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

garvinhicking wrote:*OTHER* involved plugins could be the cause. You might want to test this on an installation without other possibly influencing plugins that use Smarty; some plugins call serendipity_smarty_init() on their own (freetag, AFAIR, and maybe also staticpage). Those could interfer for disregarding the config.inc.php modifiers.
I will check this in a pristine installation later, but I need a break right now. :)

BTW, I just realized – if I disable the freetag event plugin, but leave the freetag sidebar plugin active, no plugins in that sidebar are emitted. Shouldn't we have some kind of warning mechanism for this?

YL
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Comment search

Post by yellowled »

yellowled wrote:
garvinhicking wrote:*OTHER* involved plugins could be the cause. You might want to test this on an installation without other possibly influencing plugins that use Smarty; some plugins call serendipity_smarty_init() on their own (freetag, AFAIR, and maybe also staticpage). Those could interfer for disregarding the config.inc.php modifiers.
I will check this in a pristine installation later
Pristine installation (1.6), only thing I did was activate 2k11. Same result: No entries to print.

YL
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Comment search

Post by Timbalu »

yellowled wrote:B. gives me an error 500 (I did not change the actual function's name, I just modified the line you quoted.)

C. Why should I use Smarty3 in a 1.6 blog?
  • B.
  • Well, if you do this, then you do not have to complain about getting a 500 ;-)
    'smarty_modifiername', 'smarty_modifier_functionname'
    will need the function or your mod to be renamed too.
    C.
  • Did not know, when I quoted...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply