add missing default method addCustomTag() to JDocument ? (or at least in JDocumentRAW) same as e.g. addStyleSheet()

111 views
Skip to the first unread message

Beat

unread,
8 Jul 2009, 08:28:4408/07/2009
to Joomla! CMS Development
May I suggest to add missing default method addCustomTag() to
JDocument (or at least in JDocumentRAW) same as e.g. addStyleSheet() ?

For me, it doesn't make sense to have addStyleSheet but not
addCustomTag in JDocument... elements added in addStyleSheet() are not
outputed in RAW output and those in addCustomTag shouldn't be outputed
too.

Here bug descriptions en masse:

e.g. with CB and yoo_effects and pu_arcades there are errors
apprearing when Joomla 1.5 is used in RAW output for AJAX calls, like
documented here:

http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38%3E/func,view/catid,43/id,104150/#104150

and here:

http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,/func,view/catid,77/id,91010/#91010

and here:

http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,/func,view/catid,100/id,99824/#99824

Would that be something for Joomla 1.5.13 and 1.6 too ?

(it's a little move of a var and of a function from JDocumentHTML into
JDocument)

Andrew Eddie

unread,
8 Jul 2009, 08:37:1308/07/2009
to joomla-...@googlegroups.com
I'd probably argue that they should not be implemented in JDocument at
all and should only reside in JDocumentHtml.

What are you returning in the ajax call that needs a head tag?

Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer




2009/7/8 Beat <bea...@gmail.com>:

Beat

unread,
8 Jul 2009, 08:44:3508/07/2009
to Joomla! CMS Development

I am not returning anything, but if you take a look at first link
(yoo_effects): that plugin (bot) adds the head info to all pages...
Including non-html ones.

I'm speaking of an ajax-call through joomla's index.php?format=raw

Same for many other plugins, modules and components. The use addHead
methods without checking for the output format... and plugins execute
for any output format.

So yes, agree head is needed for html only.

And addCustomTag is already in JDocumentHTML. Just that in
JDocumentRAW, all other addHead methods are in it too as they are in
JDocument that JDocumentRAW extends. So, either addStyleSheet should
be in JDocumentHTML only (and breaking most plugins and modules when
you use ajax), or by coherence addCustomTag should be at same place
than addStyleSheet (in JDocument), and be simply ignored when
outputing in RAW format.

It's just inconsistant and as is addCustomTag bugs in many components
and plugins.


On 8 July, 14:37, Andrew Eddie <mambob...@gmail.com> wrote:
> I'd probably argue that they should not be implemented in JDocument at
> all and should only reside in JDocumentHtml.
>
> What are you returning in the ajax call that needs a head tag?
>
> Regards,
> Andrew Eddiehttp://www.theartofjoomla.com- the art of becoming a Joomla developer
>
> 2009/7/8 Beat <beat...@gmail.com>:
>
>
>
>
>
> > May I suggest to add missing default method addCustomTag() to
> > JDocument (or at least in JDocumentRAW) same as e.g. addStyleSheet() ?
>
> > For me, it doesn't make sense to have addStyleSheet but not
> > addCustomTag in JDocument... elements added in addStyleSheet() are not
> > outputed in RAW output and those in addCustomTag shouldn't be outputed
> > too.
>
> > Here bug descriptions en masse:
>
> > e.g. with CB and yoo_effects and pu_arcades there are errors
> > apprearing when Joomla 1.5 is used in RAW output for AJAX calls, like
> > documented here:
>
> >http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,38...
>
> > and here:
>
> >http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,/f...
>
> > and here:
>
> >http://www.joomlapolis.com/component/option,com_joomlaboard/Itemid,/f...

Andrew Eddie

unread,
8 Jul 2009, 18:53:5108/07/2009
to joomla-...@googlegroups.com
Contact the authors of the plugins and educate them on what they are
doing wrong. I'll deprecate the HTML only methods in JDocument in
1.6.

Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer




2009/7/8 Beat <bea...@gmail.com>:

Beat

unread,
9 Jul 2009, 09:48:0109/07/2009
to Joomla! CMS Development
Hi Andrew,

This seems coherent...either way, as long as it's coherent.

Thus said, only very few methods will remain in JDocument
though...which I'm fine with ;-)

However just to be sure to "educate" right: is this the right method
to use and will it also work in Joomla 1.6 ? :

$document =& JFactory::getDocument();
if ( $document->getType() == 'html' ) {
// output what's needed to head ONLY in this case
// actually you may also want to check the template used (e.g. for
component only you don't want to output from a module....)
}

How would the second test be done ?

Probably better spend the time replying writing in the API wiki
directly, then put just url to it here, so we can try to "educate"
with clear materials.

Best Regards,
Beat


On 9 July, 00:53, Andrew Eddie <mambob...@gmail.com> wrote:
> Contact the authors of the plugins and educate them on what they are
> doing wrong.  I'll deprecate the HTML only methods in JDocument in
> 1.6.
>
> Regards,
> Andrew Eddiehttp://www.theartofjoomla.com- the art of becoming a Joomla developer
>
> 2009/7/8 Beat <beat...@gmail.com>:
>
>
>
>
>
> > I am not returning anything, but if you take a look at first link
> > (yoo_effects): that plugin (bot) adds the head info to all pages...
> > Including non-html ones.
>
> > I'm speaking of an ajax-call through joomla's index.php?format=raw
>
> > Same for many other plugins, modules and components. The use addHead
> > methods without checking for the output format... and plugins execute
> > for any output format.
>
> > So yes, agree head is needed for html only.
>
> > And addCustomTag is already in JDocumentHTML. Just that in
> > JDocumentRAW, all other addHead methods are in it too as they are in
> > JDocument that JDocumentRAW extends. So, either addStyleSheet should
> > be in JDocumentHTML only (and breaking most plugins and modules when
> > you use ajax), or by coherence addCustomTag should be at same place
> > than addStyleSheet (in JDocument), and be simply ignored when
> > outputing in RAW format.
>
> > It's just inconsistant and as is addCustomTag bugs in many components
> > and plugins.
>
> > On 8 July, 14:37, Andrew Eddie <mambob...@gmail.com> wrote:
> >> I'd probably argue that they should not be implemented in JDocument at
> >> all and should only reside in JDocumentHtml.
>
> >> What are you returning in the ajax call that needs a head tag?
>
> >> Regards,
> >> Andrew Eddiehttp://www.theartofjoomla.com-the art of becoming a Joomla developer

pollen8

unread,
30 Jul 2009, 14:29:3730/07/2009
to Joomla! CMS Development
of course (he says playind devils advote) you CAN use script includes
in an Ajax response, so there may be an argument for including this:.
Here's how

if you ajax request has the option evalScipts set to true (default it
no) then any <script> block is evaluated
However, this doesn't work directly for scripts which link to an
external script.
To get that to work you can dynamically apply them to the document
head using mootool's FBAsset.javascript() method.

Here's an example of how i overwrote JHTML::script():

function script( $filename, $path = 'media/system/js/', $mootools =
true)
{
if (JRequest::getVar( 'format' ) == 'raw') {
echo "<script type='text/javascript'>var v = new FbAsset.javascript
('" .JPATH_BASE. "', '{$path}{$filename}', {});</script>\n";
} else {
JHTML::script( $filename, $path, $mootools );
}
}


On 9 July, 15:48, Beat <beat...@gmail.com> wrote:
> Hi Andrew,
>
> This seems coherent...either way, as long as it's coherent.
>
> Thus said, only very few methods will remain in JDocument
> though...which I'm fine with ;-)
>
> However just to be sure to "educate" right: is this the right method
> to use and will it also work in Joomla 1.6 ? :
>
>                 $document               =&  JFactory::getDocument();
>                 if ( $document->getType() == 'html' ) {
>                                 // output what's needed to head ONLY in this case
>                                 // actually you may also want to check the template used (e.g. for
> component only you don't want to output from a module....)
>                 }
>
> How would the second test be done ?
>
> Probably better spend the time replying writing in the API wiki
> directly, then put just url to it here, so we can try to "educate"
> with clear materials.
>
> Best Regards,
> Beat
>
> On 9 July, 00:53, Andrew Eddie <mambob...@gmail.com> wrote:
>
> > Contact the authors of the plugins and educate them on what they are
> > doing wrong.  I'll deprecate the HTML only methods in JDocument in
> > 1.6.
>
> > Regards,
> > Andrew Eddiehttp://www.theartofjoomla.com-the art of becoming a Joomla developer
>
> > 2009/7/8 Beat <beat...@gmail.com>:
>
> > > I am not returning anything, but if you take a look at first link
> > > (yoo_effects): that plugin (bot) adds the head info to all pages...
> > > Including non-html ones.
>
> > > I'm speaking of an ajax-call through joomla's index.php?format=raw
>
> > > Same for many other plugins, modules and components. The use addHead
> > > methods without checking for the output format... and plugins execute
> > > for any output format.
>
> > > So yes, agree head is needed for html only.
>
> > > And addCustomTag is already in JDocumentHTML. Just that in
> > > JDocumentRAW, all other addHead methods are in it too as they are in
> > > JDocument that JDocumentRAW extends. So, either addStyleSheet should
> > > be in JDocumentHTML only (and breaking most plugins and modules when
> > > you use ajax), or by coherence addCustomTag should be at same place
> > > than addStyleSheet (in JDocument), and be simply ignored when
> > > outputing in RAW format.
>
> > > It's just inconsistant and as is addCustomTag bugs in many components
> > > and plugins.
>
> > > On 8 July, 14:37, Andrew Eddie <mambob...@gmail.com> wrote:
> > >> I'd probably argue that they should not be implemented in JDocument at
> > >> all and should only reside in JDocumentHtml.
>
> > >> What are you returning in the ajax call that needs a head tag?
>
> > >> Regards,
> > >> Andrew Eddiehttp://www.theartofjoomla.com-theart of becoming a Joomla developer
Reply all
Reply to author
Forward
0 new messages