To use WordPress for developing a web application

前端 未结 10 2024
旧时难觅i
旧时难觅i 2020-12-15 14:49

I\'m planning to develop a web application which will have many static pages (about, help, contact, etc.) and other dynamic pages for the application.

Most of the ti

相关标签:
10条回答
  • 2020-12-15 15:51

    Here is an alternate solution for those wishing to embed a PHP application inside a WordPress page (thus leveraging all of the CMS goodies of WordPress without having to maintain multiple frameworks/themes). Basically, all you need to do is turn your application into a page template:

    1. Write you application sans support content (header/footer)
    2. Prepend the following code to your app: <?php /* Template Name: WhateverYouWant */ ?>
    3. Upload it to your /wp-content/themes folder
    4. Create a new page in WordPress and set the page template to WhateverYouWant
    0 讨论(0)
  • 2020-12-15 15:51

    Use WordPress to make your application, and contact WP-specialist bloggers to feature you as one of the "brave" ones to use WordPress. You could probably get a few good backlinks that way and some publicity.

    Many people who back WordPress for any kind of website do so because they are highly invested in it (which happens when you spend a lot of time learning a technology). That's why you get a lot of strong opinions on questions like this. The way I see it, WordPress is just a compilation of a lot of PHP files, and if you know PHP, you know how to use that to your advantage. If it adds value (like you said, it has the membership functionality), without adding too much that is extraneous, then use it. Otherwise, keep it simple with CakePHP.

    0 讨论(0)
  • 2020-12-15 15:55

    Use WordPress on the admin side for editing the textual content (and even menus). But use a custom CakePHP app to output that content.

    CakePHP can read formatted content straight off the WordPress database tables (or a custom views). You need to define a new database connection and a new model (e.g. Post).

    Here's a sample example implementation:

    A new database connection in /app/database.php:

    class DATABASE_CONFIG {
        // ...
        var $wp = array(
                'driver' => 'mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => '<wp username>',
                'password' => '<wp password>',
                'database' => '<wp database>',
                'prefix' => 'wp_',
        );
    }
    

    A new model in /app/models/post.php:

    class Post extends AppModel {
        var $primaryKey = 'ID';
        // Could define relations
    }
    

    Any controller now can fetch the content, e.g.:

    class XxxController extends AppController {
    
        function index($postName) {
            $this->set('post', $this->Post->findByPostName($postName));
        }
    
    }
    

    And the view can simply output the HTML content of the post:

    <?php echo $post; ?>
    

    Here is a more elaborate example: http://code.google.com/p/cakephp-wordpress/.

    0 讨论(0)
  • 2020-12-15 15:55

    To me the best and the way that worked for me was given on the official WordPress documentation here

    I just prepend this following piece of code on all the PHP pages of my application

    <?php
    require('/the/path/to/your/wp-blog-header.php');
    get_header(); 
    ?>
    

    And it worked without any glitches.

    Also, if you want the WordPress footer, just append

    <?php
    get_footer();
    ?>
    

    to those files.

    Thanks to @Jesse for showing the way

    0 讨论(0)
提交回复
热议问题