How to use a JUMI file in AJAX callback on Joomla - ajax

I'm trying to use a JUMI file (a component for Joomla that allows me to get aceess to Joomla MVC) in AJAX callback. The structure is like this:
file.php that calls AJAX file is already a JUMI file.
file ajax.js (included in file.php) makes the call.
file.tooltip.php is a JUMI file which output is shown on file.php. It needs to be a JUMI because I need to access Joomla libraries to get the data it processess.
To prevent the problem that JUMI outputs a file with all the template I'm using in the Joomla call method in the end of the url in ajax.js: &tmpl=component. It works, but however it brings together all other calls for javascripts and so on contained in the template, which is bringing me to conflicts. The page is very slow and other javascript components are not working.
Does anyone know how is the best way to approuch the situation and get to a solution?
Thanks a lot!

You need to use &format=raw at the end of the url to the file you're ajax'ing to. Chances are though, that you get a server error because that "view is not supported". Easy fix, go to your site
root/components/com_jumi/views/application/
then make a copy of view.html.php called view.raw.php.
This component REALLY needs to be updated.

So you have a file, file.php, that has something like this in it?
<script type="text/javascript">
$(document).load( function() {
$('#this_id').click(function() {
$('#that_id').hide();
});
});
</script>
<div id="this_id">click me</div>
<div id="that_id">hello and goodbye!</div>
And then you want to access a file called "file.tooltip.php" that is also a Jumi file?
I don't know why that would need to be a Jumi file, it could be a simple php file that gets called in your javascript. To access the underlying Joomla libraries, you would simply invoke the appropriate library in the PHP file.
I hope this helps...
Bud

Related

How can I put Component into Module in Joomla! site?

I wonder if exists a way to put component into module without install plugin, neither component nor module.
Thanks and my apologize for my bad English.
First, should unable Editor from configuration site, in Panel Admin. Then, go to Extension -> Plugins -> TinyMCE and delete forbidden items "script".
Now, go to "create module", with custom HTML5 and put something like this:
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<div id="new-projects">
</div>
<script type="text/javascript">
$( "#new-projects" ).load( "urlOfYourComponent #idYouWouldShow" );
</script>
Thanks to Ilias cause the idea.
The only way to achieve this without installing any extensions is via a custom HTML joomla module where you'll place your component in an iframe.
Then if you want to load only the component part of the fetched page in the iframe use jquery's load function.
If i'm correct, You don't wanna install any kind of extension that do that, you ask for vanilla possibility to put component into module, so this is the answer, there is no way to put whole component into module. Partial Example: You can put article into custom HTML module or list categories into modules, but you will never see whole component into module. Why? Because component its a core thing on site, like people in building (or even the whole building) eg. house, and module is like painting on the wall, You can't put building on the painting.

FB Comments loaded via ajax div

Here's my issue, I'm trying to load a FB comments module via an AJAX div. Now, it works if I go directly to the php page, but if I load it from within the div, it doesn't. I've looked at the other posts (FB javascript SDK after jquery LOAD (ajax)), but still can't seem to get it to work, looking for clarification.
If you want to see what I'm talking about, check http://azconceptphoto.com/lindsey and check out testimonials.
Ideally, on the normal part of my site, I can just load the HTML5 code and it works fine, though for some reason it doesn't remotely work via the AJAX div. And considering the posts from before are out of date (2011), I was hoping to get more feedback on this.
Based on the code from your link you are not using any of the PrototypeJS Ajax methods to get the backend script. Ajax.Updater is the method you need to use so....
Here is my suggestion
change the definition of loadXMLDoc() to
function loadXMLDoc(div, location)
{
new Ajax.Updater(div,location,{'evalScripts':true});
}
this will update the contents of div with the contents of location. Also if the response has <script> tags in it then the javascript will be parsed and evaluated (thats the option evalScripts)

Joomla module or component to be render on a blank page

I have developed a Joomla module that does provides a form, processes its post data, does some calculations and displays the results.
The module includes a button to print the results. I'm currently using JavaScript to open a new window, paste the relevant HTML and open the print dialog.
Instead of JavaScript I would prefer to provide a separate URL for the print view and simply open that in a _blank target. This would make the application work better for people using screen readers or not having JavaScript available.
Is there any way that I can tell Joomla to not render the template along with my module? I was thinking that creating a component fixes that issue, but had to find that components are rendered into the template, too...
BTW: I have Joomla 1.5.22
To achieve what you want you have to add additional tmpl=component query string parameter to the request URL. This will disable template and module rendering.
Your URL will look something like this: index.php?option=com_xxx&view=xxx&tmpl=component
Since you are using Joomla 1.5 you can request index2.php?option=com_xxx&view=xxx and it will only render the component. Joomla 2.5 does not have index2.php so if you plan to migrate in future, don't use this option.
If you are using SEF then adding ?tmpl=component at the end on URL does the trick.
To go a step deeper... in your template directory you have component.php file, that is the file that's being loaded by tmpl param. You can copy component.php to my_component.php, do necessary changes and load your custom component template with index.php?option=com_xxx&view=xxx&tmpl=my_component
The joomla way of doing it would be to set your output to "raw", see this tut:
http://www.katcode.com/displaying-raw-output-in-joomla-by-setting-format-in-the-component/

Load content via ajax in plone page

I'm working on a website which has been developed in plone. Now I'm facing an issue, I would like to load certain content from a template via an ajax call on normal Plone page(on some event trigger).
Do I need to create any python script??If yes where has it to be placed? and moreover how do I integrate it with TAL(I guess that would be needed) but I'm not sure how.
Could anyone guide me on this with necessary pointers/docs that I should look into?It would of great help to come over my issue and get things rolling.
Thanks,
Avinash
In the "Plone Developer Documentation" there's a section for Javascripting in Plone that perfectly fits your needs
Your question is a bit vague:
From your question, it seems that you just want your ajax call to return html to populate data on the page somewhere then?
Also, it sounds like you want to do the development TTW in the ZMI? Most developers would would use an add-on product and return your ajax response.
However, you can do it TTW with page templates just fine.
Create the new page template
populate it with the template code that gives you the desired output when called within the context of content on a site. For example, http://mysite.com/plone/page/my-template
in your javascript, use a url that in the ajax call: $.ajax({url: 'http://mysite.com/plone/page/my-template', success: function(data){ $('#content').append(data);}})
It's not really anything special to do ajax within plone--just use the tools available and piece it together.

create a widget to retrieve and display data via ajax

I tried the classic ajax approach, but that throws an access denied javascript exception when trying to add a script stored on another domain.
Now, I'm sure this is possible since google populates google ads via js only; so does twitter, and the list can continue.
How I thought of it so far:
<div id="divId"></div>
<script type="text/javascript" src="http://mysite.com/script.js"></script>
The script in script.js should have changed the innerHTML attribute of the div above. Instead, I get the following message in fireBug: Access to restricted URI denied code: 1012
I googled around a bit but only found workarounds that are useless, like php proxies and such, whereas I want this widget to be copy-pasted into other peoples sites, blogs, forums, etc..
Thanks in advance for any helpful replies. :)
The behavior that you are seeing is intended and there for security reasons. You wouldn't want a third party script to make any changes to your page as that can be exploited heavily.
Instead, give your users a JavaScript snippet to embed on their page.
<script>
// do stuff here
</script>
Note that inside this snippet you can create a script tag dynamically, set the src attribute and load the actual JavaScript. This snippet that your users embed on their page has access to the entire DOM, but the script loaded externally does not.
Here's an example of the profile widget that Twitter gives out to embed on web pages:
<!-- external js, can't access or change the DOM -->
<script src="http://widgets.twimg.com/j/2/widget.js"></script>
<!-- local js, does that -->
<script>
new TWTR.Widget({
version: 2,
..
..
}).render().setUser('hulu').start();
</script>
The first script tag loads the library, while the second one which actually manipulates the page is added as code directly.
I finally found a solution that doesn't involve ajax.
I simply use
<div id="objectId"></div>
<script type="text/javascript" src="http://mysite.com/getAndDisplayData.php"></script>
<script type="text/javascript">getAndDisplayData();</script>
And in getAndDisplayData.php I generate a JS script that will create my widget inside the div above. The php file also connects to the database and retrieves all required widget data.
Apparently this is how google ads works, though I am not sure. It is certain though that they don't use ajax.

Resources