Adding standalone blog |
Hi guys, I have this site built with CI.
Standard folder structure. css, img, js folders outside the application folder. I'm replacing one of the page with a standalone simple blog (http://simpleblogphp.com/). The folder contains hundreds of files. Right now this folder sits outside the application folder, next to the css and img folders. I created a blog view and controller. Now when I navigate to the blog page I get errors. To make this blog display within my site and based on the blog's documentation I'm adding this in my blog view: PHP Code: <?php include(base_url()."/blogger/blog.php"); ?> Resulting in: Code: <h4>A PHP Error was encountered</h4> Where else can I put that blog folder so it would display correctly? Thank you in advance.
(06-07-2015, 05:04 PM)keld Wrote: Hi guys, I have this site built with CI. base_url() will get you an url. your PHP config prevents you from including files from an url. you should keep it that way in order to prevent RFI attacks. if you really need to include() something on CI, you should use CI constants. FCPATH instead of base_url() should get you what you want. but you might want to use a redirect instead.
Thanks, using
PHP Code: <?php include(FCPATH."/blogger/blog.php"); ?> The blog config file contains this PHP Code: if ($installed!='yes') { Now what's interesting is that I don't get that error and the blog displays fine if I access to it directly from the URL (mysite.com/blog/blog.php) but inserting it into a view makes the global variable not working. Is that a CI thing?
That script is apparently intended to operate as a stand-alone blog. While a CI view is capable of executing a great deal of PHP code, it is very likely that the script will have a lot of issues trying to co-exist with CI since it was never intended to work alongside CI.
You could try removing the code you've quoted and creating a helper which defines the sql_result() function to call $this->db->query() and return the query result, but you'll really have to pay attention to how it uses the result to make sure what you're returning will work with the script. |
Welcome Guest, Not a member yet? Register Sign In |