Welcome Guest, Not a member yet? Register   Sign In
  Custom validation callback technique
Posted by: El Forum - 08-30-2007, 12:59 AM - No Replies

[eluser]CodeOfficer[/eluser]
This is a question regarding CI's custom validation callback technique. As far as I can tell, validation callback methods need to be in the controller class ... which is bad in my case, as multiple controllers might deal with this sort of validation potentially.

Another way I can think to get this stuff out of my controller is to extend the validation class and put them in my custom version ... yet even that doesn't seem an attractive idea at the moment. Are there other popular methods for handling this?###


  Take a local publish and make it a view.
Posted by: El Forum - 08-29-2007, 11:29 PM - No Replies

[eluser]FastPhoto[/eluser]
Hi,

I am new to CI. Starting first project. Not the greatest CSS, XHTML programmer. I like to create websites with more visual arrangement of page components. I can create a page much faster. Currently using Shutterbug and RapidWeaver on the Mac.

I have read alot of discussion on the forums and wikis about the arrangement of views and embedding views in views, splitting up webpages into parts, etc.

Has anybody come up with a way to take a local published directory from one of the visual web designer programs and make it an operational view with proper paths to css, js, images, etc? They work on the local drive. Why not a view?

That would be way cool. The styles and templates would be managed by the website creator tool. Variables could be put into places in generated web pages where controller or model classes could assign code to. CI would basically be a variable filler and page pusher.

Maybe this has already been done. Thanks for your input to my newbie thoughts here.

DMW


  form validation
Posted by: El Forum - 08-29-2007, 08:09 PM - No Replies

[eluser]Satch[/eluser]
Hi,

I just started using ci and ran into a little problem: I'm trying to validate a form but want it returned to the same page whether it succeeded or not with the proper message. The page it should return to will look something like /blog/comments/1. The example in docs had it going to different pages which didn't work for me. Any help is appreciated.

Thanks


  Validation class with ajax submitted forms
Posted by: El Forum - 08-29-2007, 06:23 PM - No Replies

[eluser]stevefink[/eluser]
Hi all,

I have validation working without AJAX on submitted forms, however could use some guidance on the AJAXified version.

Does anyone have any code/source samples of using $this->validation etc after a form is submitted via ajax?

- sf


  Newsletter Application
Posted by: El Forum - 08-29-2007, 05:06 PM - No Replies

[eluser]huggiebear[/eluser]
I'm creating a newsletter application and it has to have three features:

1. Articles
2. Poll
3. Photo with random caption

All three of these elements have to be on the same page at the same time, so I'll lay it out so that links to the articles are on the left, the main article is in the middle and on the right is the poll and the captions.

Now do I create a single controller called newsletter, with all functions, such as getpollresults(), displaypollresults(), updatepollresults(), addpollquestion(), displayrandomcaption(), addrandomcaption() etc.

Or...

Do I have a separate controller for each, poll, that contains the poll methods, caption that contains the caption methods and display that show's it all.

I'd have thought I need the second option, but if this is the case, will I still be able to display everything on one page? I can only call a single view from a controller right?

Regards
Huggie


  Store objects in array elements
Posted by: El Forum - 08-29-2007, 04:51 PM - No Replies

[eluser]LifeSteala[/eluser]
Usually, in your controller you have an array, say $data[] which is parsed to the view, like so:

Code:
$this->load->view('View', $data);

The array would store strings like:

Code:
$data['a'] = "hello";
$data['b'] = "goodbye";
$data['c'] = "cya";

How can you create objects and store it in a,b and c?? So, $data['a'] will have object a, b will have object b, c->object c.. any idea's?


  SOLVED: CI + jQuery forms
Posted by: El Forum - 08-29-2007, 03:38 PM - No Replies

[eluser]stevefink[/eluser]
Does anyone have any experience with using jQuery forms within CI?

I have a really simple target: callback which works fine outside of CI:

Code:
$(document).ready(function() {
    // bind 'form2' and provide a simple callback function
    $('#form2').ajaxForm(function() {
        // Server should send data back in json encoding
        target: '#container'
    });  
});


all that should do is pop in the response of my script into <div id="container></div>. I'm not getting any errors, just not seeing updated content. My action method looks like this:

Code:
function photo_mod()
    {
        /**
         * Process photo modifications here. The form from photos_view.php
         * gets process in this method.
         */    
        echo  "<pre>DEBUG TEXT</pre>";
    }

Thanks all.


  Ajax Tabs: Loading views into containers!! Possible?
Posted by: El Forum - 08-29-2007, 03:37 PM - No Replies

[eluser]danfloun[/eluser]
Hi,

I am wondering if I can use this Ajax tab script to work with my CI Project.
Basically all the Ajax script does is load the pages into the tab container.

Now obviously I am using model, containers and views and because of this my tab links will be written like &lt;?php echo site_url('main/file_view'); ?&gt; instead of simply file_view.php.

The rel="ajaxcontentarea" in lthe link simply loads the content of file_view into a container.

However this doesn't work and I'm wondering if it's actually possible to use this script this way! or with slight modification.

Tabs:

Code:
<ul id="maintab" class="shadetabs">
<li class="selected"><a href="#default" rel="ajaxcontentarea">Default Tab</a></li>
<li><a href="test.htm" rel="ajaxcontentarea">Test</a></li>
<li><a href="&lt;?php echo site_url('main/file_view'); ?&gt;" rel="ajaxcontentarea">File List</a></li>
</ul>

<div id="ajaxcontentarea" class="contentstyle">
<p>This is some default tab content, embedded directly inside this space and not via Ajax. It can be shown when no tabs are automatically selected, or associated with a certain tab, in this case, the first tab.</p>
<p><b><a href="[removed] expandtab('maintab', 2)">Select 3rd tab of "maintab"</a></b></p>
</div>


//Start Ajax tabs script for UL with id="maintab" Separate multiple ids each with a comma.
startajaxtabs("maintab")

Thanks

Danny


  is this a bug?
Posted by: El Forum - 08-29-2007, 03:24 PM - No Replies

[eluser]alpar[/eluser]
I use sessions stored in a database, and enabled user agent matching.
Actually i had modified the original library to store all the data in the database, but i also checked the original library, and it seems that is the same.

when sawing the session id only 50 characters are saved like so

Code:
substr($this->CI->input->user_agent(), 0, 50)


Now imagine that the user agent is computed in such a way that the last character is a space. When you insert it in the database, MySQL will strip that off, inserting a string of length:49 characters. When re matching a string of 50 characters (with the last space) will not match a 49 character string(without it). So the session system gets useless for the user that is unfortunate enough to have such a user agent. I got one with suse linux 10.2 + firefox...

a solution: store and compare the md5 hash of the first 50 characters of the user agent.


  Nusoap in Code Igniter 1.5.4
Posted by: El Forum - 08-29-2007, 02:58 PM - No Replies

[eluser]Leonardo Radoiu[/eluser]
Hello!

After some hard time trying to figure out how I can implement nusoap library in 1.5.4 version I came up with a solution I want to share with all of you who came across the very same problem.

First, the nusoap library file that you must put in the system/libraries folder (we assume we have already there the nusoap base class named nusoap.php). I named this Nusoap_lib.php:

Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Nusoap_lib
{
   function Nusoap_lib()
   {
       require_once(BASEPATH.'libraries/nusoap'.EXT);
   }
}
?&gt;

Let's say we have a nusoap webservice named MemberWSVC saved as a controller file named MemberWSVC.php:

Code:
&lt;?php
class MemberWSVC extends Controller {
    function __construct() {
        parent::Controller();
        
        $this->load->library("Nusoap_lib");
        
        $this->nusoap_server = new soap_server();
        $this->nusoap_server->configureWSDL("MemberWSDL", "urn:MemberWSDL");
        
        $this->nusoap_server->wsdl->addComplexType(
            "MemberRecordset",
            "complexType",
            "array",
            "",
            "SOAP-ENC:Array",
            array(
                "id"=>array("name"=>"id", "type"=>"xsd:int"),
                "firstname"=>array("name"=>"firstname", "type"=>"xsd:string"),
                "lastname"=>array("name"=>"lastname", "type"=>"xsd:string")
            )
        );    
        
        $this->nusoap_server->register(
            "selectMemberInfo",
            array(
                "id" => "xsd:int",
            ),
            array("return"=>"tns:MemberRecordset"),
            "urn:MemberWSDL",
            "urn:MemberWSDL#selectMemberInfo",
            "rpc",
            "encoded",
            "Get member's info"
        );
    }
    
    function index() {
        // this just expose webservice's methods. if you put this in every method of the webservice to describe it you won't get it to work because of some post/get issues i guess


        // this is a workaround for not having get params enabled in ci
        // usually you get the nusoap webservice's wsdl by appending "?wsdl" at the end of its url

        if($this->uri->segment(3) == "wsdl") {
            $_SERVER['QUERY_STRING'] = "wsdl";
        } else {
            $_SERVER['QUERY_STRING'] = "";
        }
        
        $this->nusoap_server->service(file_get_contents("php://input"));
    }
    
    function select_member_info() {
        function selectMemberInfo($member_id) {
            $CI =& get_instance();
            $CI->load->model("Member");
            
            $CI->Member->_id = $member_id;
                        
            $row = $CI->Member->selectMemberInfo(); // the method we use to retrieve member's info as array
    
            return $row;
        }
        
        $this->nusoap_server->service(file_get_contents("php://input"));
    }
}
?&gt;

Finally, we consume the webservice with a controller named Client.php:

Code:
&lt;?php
class Client extends Controller {
    function __construct() {
        parent::Controller();

        $this->load->library("Nusoap_lib");
    }

    function index() {
        $id = $this->uri->segment(3);

        $this->nusoap_client = new soapclient($this->config->item('base_url')."/webservice.php/MemberWSVC/select_member_info/wsdl");
        
        if($this->nusoap_client->fault)
        {
            $text = 'Error: '.$this->nusoap_client->fault;
        }
        else
        {
            if ($this->nusoap_client->getError())
            {
                $text = 'Error: '.$this->nusoap_client->getError();
            }
            else
            {
                $row = $this->nusoap_client->call(
                    'selectMemberInfo',
                    array($id),
                    'urn:MemberWSDL',
                    'urn:MemberWSDL#selectMemberInfo'
                );
                
                if(count($row) > 0 && is_array($row)) {
                    $text = "The member's name is ".$row['firstname']." ".$row['lastname'];
                } else {
                    $text = "There is no such member with ID ".$id;
                }
            }
        }

        etc.
    }
?&gt;

Let's say this client will be accesible at http://localhost/webservice.php/client/12345

That's it! I hope it works for you.


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
hot-reload side effects s...
by PaulC
11 hours ago
CodeIgniter.com - Report ...
by Harry Lyre
11 hours ago
Setting baseURL in Regist...
by michalsn
Today, 12:09 AM
Update from 4.6.0 to 4.6....
by FlavioSuar
Yesterday, 04:17 AM
Sessions old files are de...
by InsiteFX
05-12-2025, 10:30 PM
Ajax post failing with Ty...
by PaulC
05-12-2025, 12:23 AM
intermittent smtp failure...
by InsiteFX
05-11-2025, 11:30 PM
MVC vs MVCS vs CodeIgnite...
by FlavioSuar
05-10-2025, 10:33 AM
CodeIgniter Shield 1.0.0 ...
by timesprayer
05-10-2025, 05:22 AM
Website Traffic Drop Afte...
by InsiteFX
05-10-2025, 04:23 AM

Forum Statistics
» Members: 145,991
» Latest member: busywood
» Forum threads: 78,389
» Forum posts: 379,450

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB