Alright, I have a wordpress site, that I want to have a clientportal built with codeigniter in it. For the sake of continued theme, I would like to have the codeigniter program where the page/text would normally be.
Here is the site http://foretruss.com/wordpress/?page_id=8 you can see the error I get when I have php_exec plugin installed and use the snippet.
Any Idea's/help/word of advice?
It's a bad idea to mix and match frameworks like Wordpress and CodeIgniter. There are bound to be collisions of variables and constants; not to mention the substantial increase in resources required to load the page.
If you REALLY need to do this, though, you can try loading your CI setup into a separate directory from your WP setup and use AHAH or an iframe to pull everything over. Granted, you won't get the SEO benefits, but at the same time it's probably the "best" way to go.
For the record, the error that you're getting from CI is a header error. Basically, it's trying to put something in your cookies or write to the HTTP request headers, except they've already been signed, sealed, and delivered (hence the error). Perhaps if you turn off sessions in CI, you'll have better luck. The alternative is to load up the index.php file for WP and put a big
ob_start();
right at the beginning.
See another post on combining CI and WP: Getting posts from Wordpress to out of WP in codeigniter view
Related
I'm creating a script that gets the content and meta of wordpress posts for an app, doing queries directly on the database because it's way faster than including the wp functions. However the problem is that the post content is saved into the db without formatting. I know that I can get it using
apply_filters('the_content', $content)
but as I said, I would like to avoid wp functions because they are really slow.
Is there any way to "simulate" apply_filters manually?
Is there a better(faster) way to include a wp function other than
require('../wp-load.php');
which seems to be very slow?
The “cheap” method would be including the file wp-includes/formatting.php (and maybe others) and running your code through the desired filter functions, such as wpautop().
However, this does not guarantee that the content is formatted like your WordPress blog – especially because it won't apply the modifications made by plugins. Also, if new WordPress versions introduce new or different filters, your code will not work with them without modifications.
I would indeed recommend including wp-load.php and working with the WP filter API.
I don't think it's overly “slow” (however you may define it), but if performance is an issue, I would recommend reconsidering your architecture.
For example, if you want a website to display contents from your WordPress database, don't pull and render the contents on each page request. Instead, use a caching solution – either one of those that already exist for WordPress, or one on the server level (e.g. Varnish), or you can even implement your own cache, by storing pre-rendered pages and delivering them (semi-)statically.
I have a wordpress installation I'd like to get rid off. It's been constant work over the past year keeping up with various updates and changes and managing differenet plugins. I've realized I don't need that much functionality and would be perfectly happy with static pages. If I manage to drop the installation I could also speed things up a lot and integrate the content more easily in the rest of our site.
I'm trying to find a PHP or Perl package which I can use to easily query the existing WP DB. Basically, I want to keep the DB and throw away the frontend and backend to WP. Then I just want to add a very minimal layer of PHP or Perl code on top to show the posts in the DB including meta data.
In case there is no package that can make this job easier, is there some concise overview of the SQL queries I will need? I know I can go digging for them in the codebase, but maybe there is someone who has already done this. Googling around didn't immediately turn up useful results.
Maybe you want give a try to jekyll or octopress.
I'm using Wordpress to manage posts in my website, but I don't want to use Wordpress template/visualization. I will use it only to manage the content and program a bit to display the content in my website.
Well, I can access the Wordpress database and load the content with my own queries. But I want to know if is viable to use Wordpress to create the bridge between my site and the Wordpress database.
Simplifying, I want to know if Wordpress provides methods like getAllPosts(), getAllComments that already manage the database connection, queries and returns some objects or I need to build this in my application.
Not native wordpress, but this is very "viable" through plugins. Example: http://code.google.com/p/wordpress-posts-api/ that claims to do what you want for posts, and you could expand to load comments as well - or you may find an exact plug in that you want with a bit of searching.
I've never actually used one written by someone else for this, but have built similar functionality to expose posts etc for XML feeds (then displayed in Flash, for example). Relatively easy if you start with someone else's plug-in and expand.
Just one word of warning - these plugins are great as the operate in the full WordPress environment, so are easy to run. The downside is that they operate in the full WordPress environment, and are therefore inefficient under high stress. If you're going to hammer it, I'd write a caching buffer first, and only make the full call to WordPress when the cache expires.
I am trying to integrate to a joomla project, a list of php pages setup that update their content from db, and give select options to the user, to navigate through this content. Select is also dynamic. All dynamic features work with url parsing.
For example, pageone.php gets some data from db and creates a list of selectable links to page2.php?data=fetcheddata. Page 2 gets url variables and performs queries to db to select the data.
How am I going to integrate this to Joomla? Should I make a module to include the basic php page, and how url parsing will then work? Should I make an i-frame wrapper? Please enlighten me..
You just described the way Joomla works. Depending on the content you want to present, there may already be an extension that does that, or at least does something close that can be modified. Without any more details it is hard to say, but what you are describing could probably be accomplished with a CCK http://extensions.joomla.org/extensions/news-production/content-construction. You could definitely do it with a combination of Chronoforms and Chrono Connectivity -
http://extensions.joomla.org/extensions/contacts-and-feedback/forms/1508
http://extensions.joomla.org/extensions/directory-a-documentation/faq/5661
If not, then you will probably need to code a component - http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1
1) iframe solution is the easiest one. But it has its limitations...
2) you can write Joomla component (not a module) that will do the job, but I'm afraid in this case you will either have to switch to Joomla URL format... unless you find some trick how to workaround that.
If your site is not very complex a simple approach is to write your application in plain php, and integrate your Joomla template to your application so your visitors can't tell any difference. Then, you will place links from your Joomla to your application and vice-versa accordingly.
However, the best approach if you are more familiar with Joomla is to develop a component. Here you can understand the difference between Joomla Components, Modules and Plugins. Please read Joomla documentation for further understanding:
http://docs.joomla.org/Extension
http://docs.joomla.org/Component
I am just getting started with CodeIgniter, and I am trying to hash out my regular modules/functions to get them working properly within the MVC framework. I have a few specific questions for anyone who has a strong CodeIgniter background:
SESSIONS
The CodeIgniter session stores session data on the client side in a cookie, which just isn't going to work for me. I know there are a few replacements for it, or I could build my own library/helper; but I just don't see any benefit over just using $_SESSION.
If I just use $_SESSION, will I have any problems with the rest of the framework? Does any other part of the framework depend on using the CodeIgniter session?
I feel a bit weird about stepping outside the framework for something so basic, but I am pretty comfortable with plain PHP. I am basically just looking to use CodeIgniter for MVC, and to enforce a more modular aspect for my projects.
CODE FLOW & CONFIG
I have a few config items that need to be done before almost anything else.
For example, say I have a constant APP_LIVE, which is set true/false based on the name of the current server. This has to happen really early as paths, error reporting, the CodeIgniter system, and application folders, etc. will be set based on it.
The problem is that the system_folder, and application_folder (which will be set based on which server the code is running on) are set first thing in the index.php file, before any of the configs have loaded.
Also, I have a functions that check for things in the URL, and may redirect before the page ever loads. For example, some pages need to enfore the presence of www. in the URL (for SEO), track affiliates, visitor sources, marketing flags, etc.
Where is the best place to put things like this that have to happen really early? I know there is a config file, an autoload file, a constants file, etc., but those are too late for some items. Is it a bad practice to simply put these things into the top of the main index.php file, or to make an include there to a global config file? Again, I feel like I am stepping outside the framework, and wonder if I'm just doing that because I don't have a solid understanding of it yet?
LAYOUT / HEADER FOOTER
Like most people, I have a top header, navigation, footer, etc. I am used to just having them in files, which are included into my page template. I believe I can do that the same way by just making them views and including them into my main page view. Is that the best way to go? Some of them need a bit of data; like what page they are on for the navigation, etc. What's the best way to handle navigation, shared header/footer, etc.?
The newly released CI 1.7 handles sessions in the database (if you're using one).
However, CI is designed to be loosely coupled, so you shouldn't notice any major issues if you decide to use $_SESSION instead.
For your header / footer / navigation, you could create (for example) headerview.php, footerview.php, and contentview.php, and pass data to your views by doing something like this in the controller:
$data['title'] = 'about us';
$data['content'] = 'hello world!';
$this->load->view('headerview', $data);
$this->load->view('contentview', $data);
$this->load->view('footerview');
Basically, you can treat these views exactly like includes, but with the added benefit that you can change the variables within. I would steer clear of calling other views from within views, but that might just be me.
I've made additions to index.php myself once or twice, to set initial values and such, and have never had a problem with it.
Congratulations on your choice of framework; I'm sure you won't be disappointed. ;)
You can either have multiple load->view lines in every controller but I personally find it coupled. I strongly suggest that you take a look at hooks in CodeIgniter where you can define functions that would be automatically run after each controller/method (a fine example of AOP).
Actually the $_SESSION array seems to get unset so you can't use the native PHP sessions (at least on 1.7). However in CodeIgniter wiki there's a session class that uses the native php sessions - you can use it the same way as the other, but it stores only session_id in the cookie. Here it is:
http://codeigniter.com/wiki/Native_session/
#lacho I created my own auth library on $_SESSION. and it works fine on 1.7.
I believe $_SESSION is much more secure since CI 'sessions' are cookies that are stored on the client side which are classified as 'user-passed-information' that can't be trusted.
You can try with native using your own session class
http://www.moreofless.co.uk/using-native-php-sessions-with-codeigniter/