Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Do this in CI view:

    <?php
        // get the empty page we just created
        $link = file_get_contents('https://my-wordpress-site.com/my-register-page-tpl-9929392');
    
        // break it apart
        $delimiter = 'CI_PLACEHOLDER';
        $parts = explode ( $delimiter , $link);
        // print the header stuff
        echo $parts[0];
    
        /* HERE PUT THE CONTENT OF YOUR VIEW */
    
        // print the footer stuff
        echo $parts[1];

    TL;DR
    You must have followed;:
    https://github.com/AdeptMarketing/Wordpress_CI
    https://www.marketingadept.com/blog/integrating-codeigniter-and-wordpress/

    or some other article that gives a similar solution.

    I have been thinking about this problem recently, and I would like to share with you other possible ways of doing this:
    1 – Just copy. Place codeigniter directory inside wordpress root folder and rename codeigniter folder to the slug of the main page you want to be handled by codeingiter (imagine renaming the codeigniter folder to “resgister” or something). WordPress does not execute if we call an existing file, in our case, since register exists… we get a codeingiter page. The problem is that we cannot benefit from wordpress functionality and themes.

    2 – Use a plugin like https://www.ads-software.com/plugins/wp-igniter/
    After install and a little guessing on how to fill the application path.. I got a codeigniter page instead of wordpress on the page I wanted. I haven’t got very far with this plugin, but it seemed no different that the previous approach… when I called “get_template_part” on the codeigniter view, i got a php error… seems like we don’t get direct access to WP functionality.

    3 – The solution you are following and presented https://github.com/AdeptMarketing/Wordpress_CI
    Seems so far one of the best solutions, however… requires messing with WP core files that get overwriten on each upgrade, and messing with index.php of codeignter… not so good also. But it is a workingk solution, as long as you accept these caveats.

    4 – use https://codex.www.ads-software.com/Function_Reference/wp_remote_get
    to call CI and echo the result. This would mean your CI should be on a different place than WP and you would call the functions as if CI was an API to your WP.
    This would imply that you are comfortable coding PHP on a custom template page.
    I think this would work, but I don’t know how would work the following: Session, cookie, crsf tokens…
    It may be a good solution, but it has to be carefully planned on first time, and I haven’t done that.

    5 – Use ajax calls instead of wp_remote_get from WP to CI, like the previous point.

    6 – Use iFrame and inside place your CI app. This works. However you don’t get access to WP functions, you probably have to manage the CI app by ajax or generate the iframe src=”” attribute in a way that allows you navigation within the CI app. Another problem is that iFrame height is not a friend… you have to set it’s height explicitly and it’s impossible to autoadjust (there are some javascript workarounds, but it’s not as clean as it should be).

    7 – The solution I’ve been trying now seems a bit more clean.
    7.1 – Copy Codeigniter folder into the wordpress root folder
    7.2 – rename codeingiter folder to your desired page name, like “register” (note that this part can still be improved with WP 404 hooks)
    7.3 – create a page in wordpress with a hard to guess slug like “register-tpl-9929392”.
    7.4 – On that page, write only something like “CI_PLACEHOLDER”
    7.6 – On your view do this

    <?php
        // get the empty page we just created
        $link = file_get_contents('https://mysite.com/register-tpl-9929392');
    
        // break it apart
        $delimiter = 'CI_PLACEHOLDER';
        $parts = explode ( $delimiter , $link);
        // print the header stuff
        echo $parts[0];
    
        /* HERE PUT THE CONTENT OF YOUR VIEW */
    
        // print the footer stuff
        echo $parts[1];

    This will give you the content of Codeingiter code inside the layout of a wordpress page.
    What you don’t have is access to WP functions.
    You can imporove this one, CI MY_View.php or MY_Controller.php that does this fetching and wrapping for you.
    I tested with CI3.0.1 and Sessions seemed to be working good.

    What do you, or anyone else, think?

    Me 2. I have the same problem as Cronolis.
    Had no problems before worpress 3.1.3.
    Any help is wellcome.

Viewing 2 replies - 1 through 2 (of 2 total)