Welcome Guest, Not a member yet? Register   Sign In
How to implement the PHPAJAX class in CI
#1

[eluser]bhakti.thakkar[/eluser]
Hello,
I have a class phpajax which i want to implement in CI. There is folder of phpajax/ and inside that folder all files are there. They include JS files as well. I have placed this folder in the application/libraries folder. How will i load the class as the class file is inside the application/libraries/phpajax/ folder?
#2

[eluser]rogierb[/eluser]
CI is just PHP. If you want to work with a non-CI class, just load it like you would normaly do (require, include etc.) and create your instance.

The better way would be to convert the class to a 'proper' CI class so you can load it into the CI super object.
#3

[eluser]bhakti.thakkar[/eluser]
Thanks rogierb,
I uploaded the main class file directly in the app/libraries folder, subsequently changed the paths in the class file and auto loaded the class in autoload.php
There is no error but hope it is working the way it should

Thanks for your reply
#4

[eluser]bhakti.thakkar[/eluser]
The class files are there in the application/libraries folder. No error but when i try to access it there is Object expected error
Also i am trying to check if the class is loaded or not and to my disappointment its not loaded. I have loaded the library in autoload.php. But somehow its failing.
The main class file is in application/libraries/. The filename is Phpajax.php and the class name is also class Phpajax
autoload.php:
Code:
$autoload['libraries'] = array('database', 'site_sentry', 'session','phpajax');

actually to use the class in conventional PHP we have to do these:
phpajax::init();
and then
<?php phpajax_js($inc.'phpajax/');?>
where $inc is pointing to my path of the phpajax folder

how do i do the same in CI or how do i check if the class is loaded or not??
#5

[eluser]rogierb[/eluser]
Hi

did you read http://ellislab.com/codeigniter/user-gui...aries.html?

This will explain most of you questions regarding CI libraries.

In short: $this->phpajax->init();
#6

[eluser]bhakti.thakkar[/eluser]
Yes rogierb,
I did do that as well but still a problem. To be sure that the class is loaded or not i checked some print statements and they are printed from the class files that means tat the class is loaded
#7

[eluser]bhakti.thakkar[/eluser]
[quote author="rogierb" date="1271347313"]Hi

did you read http://ellislab.com/codeigniter/user-gui...aries.html?

This will explain most of you questions regarding CI libraries.

In short: $this->phpajax->init();[/quote]

and for the second call

Code:
<?php phpajax_js($inc.‘phpajax/’);?>

i have done this
actually phpajax_js() is a method inside phpajax class.
<?php phpajax_js(base_url().'system/application/libraries/phpajax/');?>
is this correct?




Theme © iAndrew 2016 - Forum software by © MyBB