Not compatible with Joomgallery, now what?

fvogels
fvogels
Offline
0
An article I read:


While developing and supporting JoomGallery 1.5.5 we detected a problem which is related to very many third party system plugins.

In our opinion, these plugins don't respect a certain attribute of Joomla by what problems may occur if the site uses search engine friendly URLs.

We want to explain this correlation here and ask the developers of these plugins to check their code concerning this matter and to fix it where appropriate.

For illustration we will have to go into greater detail: As probably known by many developers there are four system plugin events in Joomla at the moment which are triggered in the following order: 'onAfterInitialise', 'onAfterRoute', 'onAfterDispatch' and 'onAfterRender'.

In the following primarily the events 'onAfterInitialise' and 'onAfterRoute' are important as well as a core parameter of Joomla called 'format'. This parameter, which usually is delivered within a URL, determines which document type (see $document->getType()) of Joomla shall be rendered. By default, this is 'html', thus an ordinary HTML page. Because of that 'format' isn't usually delivered for HTML pages (the default value 'html' is used then).
Other possible values are 'error', 'feed', 'pdf' and 'raw' (they match with the sub-directory names of folder 'libraries/joomla/document'). For example, if you want to create a PDF file and output it you will have to use 'format=pdf' explicitly in the URL so that Joomla renders this document type automatically.

The actual problem can only occur if search engine friendly URLs are enabled in Joomla (it doesn't matter whether it's the Joomla Core SEF or a third party SEF component). Since 'format' isn't explicitly in the URL anymore now (but implicitly in the SEF URL), Joomla isn't able to "know" that another document type than 'html' is requested until event 'onAfterRoute': Only now the SEF URL was parsed and 'format' is available explicitly again.

However, this alone still isn't responsible for the actual problem. That one occurs not until a system plugin is installed and enabled which fulfils the following conditions:

It uses the event 'onAfterInitialise' or the constructor.
In at least one of these, it calls the document library of Joomla.
This may happen directly with:

$document =& JFactory::getDocument();

or also indirectly with e.g.:

$mainframe->addCustomHeadTag($html);

If these conditions are fulfilled (which happens with very many system plugins unfortunately), 'JDocument' is loaded before 'format' is known explicitly to the system.

Thus the line

$instance->setType($ntype);

of function 'getInstance()' in file 'libraries/joomla/document/document.php' irrevocably determines the document type of the current request with 'html' (this cannot be changed later on)!

An extension which requests another document type (e.g. JoomGallery requires 'format=raw' for displaying a single image) cannot work correctly anymore with that.

Conclusion

Since 'format=html' is determined afore it's sure that definitly 'html' is requested because of these certain system plugins we think that these plugins are responsible for the problem.

Plugins which want to change the HTML output of a page shouldn't do that until it's definitly sure that an HTML page is actually requested. This is the case at event 'onAfterRoute' at the earliest.

We hope that many developers among you read this text und try to rewrite the plugins which call 'JDocument' in order to let them only use the events 'onAfterRoute', 'onAfterDispatch' and 'onAfterRender'. Tests on our site have shown that this is mostly practicable without much effort.

Thank you for reading this very theoretical text!
Responses (8)
  • Accepted Answer

    Saturday, December 22 2012, 05:10 PM - #Permalink
    0
    hello!

    first of, thanks for taking the time to write such a long and complete post :)
    but.. after reading all it.. I'm not sure to understand what you're exposing.
    the title of this post is "not compatible with Joomgallery"...

    what does Music Collection have to do with Joomgallery? as far as I understand, this article talks about plugins (for Joomgallery, I guess, although the plugin events described are those for joomla's native com_content component)

    so, forgive me for this question, but... what's the problem? :) is this related to Music Collection somehow?
    The reply is currently minimized Show
  • Accepted Answer

    fvogels
    fvogels
    Offline
    Saturday, December 22 2012, 05:17 PM - #Permalink
    0
    Hello Germi
    Tnx for the quick response.

    The text I put in the first post is what I received from Joomgallery.

    The problem is: when I enable the system plugin of muscol, no photos will be showed. When I disable the system plugin, well you know:-)

    So Joomgallery and Music Collection will not work together.
    My website is www.backtonormandy.org, a tribute website for D-Day and beyond. MusCol is visible in Audio link in the menu
    Hope you have an idea...
    Best regards Fred
    The reply is currently minimized Show
  • Accepted Answer

    Saturday, December 22 2012, 05:21 PM - #Permalink
    0
    ahh..! ok, I see. it's when you enable our SYSTEM plugin. correct?
    our system plugin is actually very simple, all it does is to define a JavaScript variable named "base".
    I'm thinkin that the problem is probably that JoomGallery is defining a similar variable (I mean, amybe with the same name), hence the incompatibility.

    I mean, that's all I can think of really, because that's all our system plugin does..

    this is the plugin that causes problems.. correct?
    The reply is currently minimized Show
  • Accepted Answer

    fvogels
    fvogels
    Offline
    Saturday, December 22 2012, 05:51 PM - #Permalink
    0
    Yep.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, January 04 2013, 05:05 PM - #Permalink
    0
    sorry, I lost track of this thread. did you made any improvements on this?
    the plugin still causes problems?
    The reply is currently minimized Show
  • Accepted Answer

    fvogels
    fvogels
    Offline
    Friday, January 04 2013, 05:06 PM - #Permalink
    0
    Yes, I had to disable the plugin.
    The reply is currently minimized Show
  • Accepted Answer

    Friday, January 04 2013, 05:15 PM - #Permalink
    0
    and did that cause any problems with song playback on Music Collection?
    The reply is currently minimized Show
  • Accepted Answer

    fvogels
    fvogels
    Offline
    Friday, January 04 2013, 05:26 PM - #Permalink
    0
    The basics of Music Collection playing audio still works: http://www.backtonormandy.org/audio.html.
    But other thins like playlist, contentstats, modules don't work.
    Before I forget: all the best for 2013
    The reply is currently minimized Show
Your Reply