3

I'm developing a Joomla component where I have a treeview in the sidebar with the content of a database table. When clicking a node of this sidebar I want to show the children nodes in the main part of the window as a list (as the windows explorer does). For what I have been reading the best way to do this is an ajax request like explained here.

I link to the url in each node: href="index.php?option=com_nautilus&task=datalist&format=raw"

In controller.php I add:

Blockquote

public function datalist() { $this->input->set('view', 'Datalist'); parent::display(); } 

I create /views/datalist with the file view.raw.php

Blockquote

<?php defined('_JEXEC') or die; jimport('joomla.application.component.view'); class SimilarViewDatalist extends JViewLegacy { function display($tpl = null) { parent::display($tpl); } } 

and /views/datalist/tmpl with the file default.php

Blockquote

 <?php echo "Hello World from /views/datalist/tmpl/default.php"; 

But I get:

An error has occurred. 500 View class not found [class, file]: nautilusViewDatalist, C:\xampp\apps\joomla\htdocs\administrator\components\com_nautilus\views\dataList\view.raw.php

2 Answers 2

3

Your component's name is com_nautilus. With Joomla MVC your controller is looking for a class called "nautilusViewDatalist" in the file view.raw.php but you named your class "SimilarViewDatalist". That's were the error 500 comes from.

2

How to Implement Ajax in Joomla Component

Create Controller File Where you will send ajax request from javascript to PHP

controller.php

<?php defined('_JEXEC') or die('Access Deny'); jimport('joomla.application.component.controller'); class OpenChatController extends JController { function saveChatViaAjax() { $app=JFactory::getApplication(); $jinput=$app->input; $res=array(); //Implement Your Logic i am giving some sample response $res['status']=true; $res['msg']=$jinput->get('msg'); echo json_encode($res); $app->close(); } } 

From View Page You will send Ajax request using Jquery(also you can use native javascript xhr)

<script> $(document).ready(function() { //Sending Ajax Request to saveChatViaAjax method on Controller OpenChatController var param={}; param.option='com_openchat'; param.task='saveChatViaAjax'; param.msg='Please save this mesage'; $.post('index.php',param,function(res){ console.log(res); }); }); </script> 

For more info You can download https://f10df5600a7c9a74bb22e6b8df498775b8acd045.googledrive.com/host/0Bwk7CPC93wgSVjZUR2c2enNnZ3M/Source%20Codes/Joomla%20OpenChat%20V1.0.0%20Source%20Code/com_openchat-v1.0.0.zip

You can watch whole video series https://www.youtube.com/playlist?list=PL7kkxuLFYIDOrj395REpd0golrCV7XLcY

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.