Page 1 of 1

Addressing the downloadmanager

Posted: Thu Mar 05, 2009 12:18 pm
by yellowled
Sometimes I use constructs like this

Code: Select all

{if $view == 'entry'} ... {elseif $view == 'category} ... {/if}
to emit code i.e. in the sidebar depending on the "location" a user is in a blog. There are also possibilities to check whether a user is visiting the contact form or pages created by an event plugin.

What I need now (and can't figure out myself) is a way to detemine whether a user is visiting any page created by the download manager plugin. Any hints?

YL

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 12:23 pm
by garvinhicking
Hi!

Hm, I think the current logic of the downloadmanager plugin (I hate that one) doesn'T feature a possibility to distinct it.

You could try to change this code:

Code: Select all

                case 'entry_display' :
                    if ($this->selected()) {
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                        } else {
                            $eventData = array ('clean_page' => true);
                        }
                    }
                    return true;

                    break;
to:

Code: Select all

                case 'entry_display' :
                    if ($this->selected()) {
                        $serendipity['view'] = 'downloadmanager';
                        define('IS_DOWNLOADMANAGER', 'true');
                        if (is_array($eventData)) {
                            $eventData['clean_page'] = true;
                        } else {
                            $eventData = array ('clean_page' => true);
                        }
                    }
                    return true;

                    break;
and later in your smarty code try to either check $view (I believe this won't work with current mechanism) or "{if (defined('IS_DOWNLOADMANAGER'))}...{/if}".

HTH,
Garvin

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 12:58 pm
by yellowled
garvinhicking wrote:I think the current logic of the downloadmanager plugin (I hate that one)
I was gonna say: who doesn't? I have never really used it before, but man, it's a PITA! Emits horrible HTML code, too.
garvinhicking wrote:doesn'T feature a possibility to distinct it
I tested some of the variables used in the .tpl files (which, BTW, are more or less pointless since you can only modifiy the emitted HTML - did I mention it's horrible? - to a certain point), but none of them worked, so I'm pretty sure it doesn't have that.
garvinhicking wrote:You could try to change this code:
Hm, thanks, I'll keep that in mind. However, I'm not really comfortable with hacking a plugin - there's always the matter of backporting the changes in case of a plugin upgrade, which I tend to forget :mrgreen:

Maybe there's another solution in this particular project.

YL

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 1:31 pm
by garvinhicking
Hi!
Maybe there's another solution in this particular project.
No, there isn't. I was thkning you tell me if the patch worked, and if it did, I'd put it into the official plugin :-)

Regards,
Garvin

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 1:44 pm
by yellowled
garvinhicking wrote:I was thkning you tell me if the patch worked, and if it did, I'd put it into the official plugin :-)
Why didn't you say so? I LOVE being a guinea pig! :)

I'll test it asap and report back.

YL

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 1:47 pm
by yellowled
Hm, one thing, though:
garvinhicking wrote:and later in your smarty code try to either check $view (I believe this won't work with current mechanism) or "{if (defined('IS_DOWNLOADMANAGER'))}...{/if}".
In my project, it wouldn't suffice just to test whether one is on any page generated by the download manager, I would also need to distinguish between various categories in the download manager. I.e. emit different code if cat A, cat B, cat C, is visited.

Does this code cover that?

YL

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 2:00 pm
by garvinhicking
Hi!
Does this code cover that?
No, that is even harder to do, and I refuse to dig so much into the plugin *ggg*

Regards,
Garvin

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 2:11 pm
by yellowled
garvinhicking wrote:No, that is even harder to do, and I refuse to dig so much into the plugin *ggg*
Perfectly fine. Maybe we should just throw it away and have someone rewrite it from scratch. *g*

Funny thing, though - all of the .tpl files of the download manager use a variable $pagetitle, which should be unique to each page generated by the dl manager. But I can seem to access that variable from my index.tpl - or can I?

YL

Re: Addressing the downloadmanager

Posted: Thu Mar 05, 2009 3:29 pm
by Don Chambers
I think Grischa was maintaining that plugin, at least for awhile he was. At the time, he was very receptive to ideas. I once suggested a bunch of HTML improvements to it, but I think that was around the time he got really busy and had little time for s9y development. Maybe you can contact him personally and work out an update to the plugin together?