CodeIgniter Forums
Including non CodeIgniter scripts - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Including non CodeIgniter scripts (/showthread.php?tid=19114)

Pages: 1 2


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]PHP Creative[/eluser]
I am using a php/ajax star rating script. When I try to include it into a view using a php include it creates php conflicts with CodeIgniter. The script works perfectly outside CodeIgniter

My question is there anyway to include other scripts without creating conflicts with CodeIgniter.


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]jedd[/eluser]
Quote:My question is there anyway to include other scripts without creating conflicts with CodeIgniter.

If I answered : yes ... would you find that irritating, or would the comfort of having an answer as vague as 'conflicts with CodeIgniter' offset that?


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]PHP Creative[/eluser]
lol


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]Tom Schlick[/eluser]
we need alot more information. please post the script along with your code that you used to try to integrate it. you can't just say it doesn't work help me.


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]PHP Creative[/eluser]
This is the code in question - http://msteigerwalt.com/widgets/ratings/v1.2/

Quote:A PHP Error was encountered
Severity: Notice

Message: Undefined index: vote

Filename: CodeIgniter_1.7.1/ratings.php

Line Number: 247

Code:
if ($_POST['vote'] && $_POST['id']) {
    $r = new RabidRatings();
    $r->doVote($_POST['id'], $_POST['vote']);
};


The error comes from this section ratings.php (above).

I am simply including demo.php into a view.


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]Tom Schlick[/eluser]
try

Code:
$this->input->post('vote');

and where are you including the rabid ratings? if its a php class then make it a library and use the load library function


Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]PHP Creative[/eluser]
Thanks very much.

Code:
<?php require_once("ratings.php"); $rr = new RabidRatings(); ?>
                
<<<javacript/css files>>>



    &lt;?php
        for ($i = 1; $i < 5; $i++) {
            $rr->showStars("myArticle$i");
        }
    ?&gt;




I dont think it can be a library because it is called in the javascript...

Code:
window.addEvent('domready', function(e) {
    var rating = new RabidRatings({url:'ratings.php'});
});



Including non CodeIgniter scripts - El Forum - 05-28-2009

[eluser]garymardell[/eluser]
It may take abit of shuffling code around to make it work the ci way. Have whatever class there is as a library and anything being called by javascript as a controller.


Including non CodeIgniter scripts - El Forum - 05-29-2009

[eluser]KieranA[/eluser]
Take into account that "if ($_POST['var'])" will return an Notice error, to fix that you can use the CodeIgniter post - However on the included script you could just change that statement to "if (isset($_POST['var']))" and no errors would occur, and it would allow you to post the value of 0 too.


Including non CodeIgniter scripts - El Forum - 06-25-2010

[eluser]TheIgniter[/eluser]
Excuse me! I'm stuck, i create the rabid librarie but i dont know how call the rating librarie from the js :

Code:
window.addEvent('domready', function(e) {
    var rating = new RabidRatings({url:'ratings.php'});
});

Please, could you guys help me.


Fixed :

I create a controller to load the librarie and editing the url in the js file to :
Code:
var rating = new RabidRatings({url:'http://localhost/project/index.php/yourcontroller/loadlib'});