"Call to undefined method JDocumentRAW::addCustomTag()" while writing plugin

238 views
Skip to first unread message

Jose P. Espinal

unread,
Sep 12, 2010, 5:34:27 PM9/12/10
to joomla-de...@googlegroups.com
Hello,

I'm new to Joomla development. After reading some good examples at
http://docs.joomla.org/Developers , I decided to make a plugin.

The idea of the plugin was simple, to include JQuery and run it in 'no
conflict mode'. The problem is that it actually works, BUT when I turn
on 'Firebug', it shows that in some moment of the process, this error is
displayed:

"Call to undefined method JDocumentRAW::addCustomTag()"

As far as I've been reading, I think that JDocumentRAW inherits from
JDocument, wich is (JDocument) an abstract class (please correct me if
I'm wrong).

In my code, I do NOT call JDocumentRAW, or even JDocumentHTML,

This is the code that seems to be yielding the error:

Note: My plugin is located in 'system' directory.


*Code:*
function onAfterInitialise() {

global $mainframe;

$script = "<script type='text/javascript' src='" . JURI::root()
. "components/com_virtuemart/js/jquery.js'></script>\n";
$script .= "<script type='text/javascript'>\$jpe =
jQuery.noConflict(); </script>";

$doc =& JFactory::getDocument();
$doc->addCustomTag($script);

return true;
}


I've noticed that if I wrap the like that uses 'addCustomTag' with this:


*Code:*
if($doc->getType() != 'raw') {
$doc->addCustomTag($script);
}

The error disappears and the plugin works as expected too.

My questions are:
- How do I know if it is the correct moment to call certain type of Methods?
- Could someone point me to the correct documentation about the concept
of raw data in Joomla?
(I have an idea, more or less, but not completely clear).
Something indicating when in the Joomla API execution we have 'raw',
'html' or other type of data would be great.
- In your oppinion, do I need to buy a Joomla development book, or it
would be enought with the information available online?


Regards,

--
Jose P. Espinal
http://www.eslackware.com
http://www.asteriskfaqs.org
IRC: [OFTC|FreeNode]
Khratos @ #slackware | #asterisk/-doc/-bugs

Ian MacLennan

unread,
Sep 12, 2010, 7:57:07 PM9/12/10
to joomla-de...@googlegroups.com
Anytime you include a format parameter in the query string with a value other than PDF, FEED or HTML the raw doctype is used.  Raw is generally used for any type of AJAX amongst other things.

Ian


--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.


dudee

unread,
Sep 12, 2010, 9:58:05 PM9/12/10
to joomla-de...@googlegroups.com
I would make the doc condition like this:

 if($doc->getType() == 'html')....

So only inlcudes jquery for html specifically. You dont want to include for feeds or pdf's.

I believe Joomla also recognizes file extenstions with .feed, .pdf or .raw. A alternative method to using the format parameter in the url.

Jose P. Espinal

unread,
Sep 12, 2010, 10:09:25 PM9/12/10
to joomla-de...@googlegroups.com
Thank you for your suggestion, and all other members that have summited
their opinion. It's greatly appreciated.

I'll make the correction indicated in order to avoid problems when the
document is not html.

Thanks again,

> <mailto:joomla-de...@googlegroups.com>.


> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com

> <mailto:joomla-dev-general%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-de...@googlegroups.com

> <mailto:joomla-de...@googlegroups.com>.


> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com

> <mailto:joomla-dev-general%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Joomla! General Development" group.
> To post to this group, send an email to
> joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
> joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/joomla-dev-general?hl=en-GB.

--

dudee

unread,
Sep 12, 2010, 11:48:31 PM9/12/10
to joomla-de...@googlegroups.com
This is a good way to implement Jquery. Can easily deactivate it. Will be using this method in future projects. Thank you for the helpful post.

Andy
Reply all
Reply to author
Forward
0 new messages