Template PageCallback and Wordpress

TerminalAddict

Active member
I'm attempting to create a single page application that gets some stuff from wordpress, and displays it in the page.
Reasons I'm using wordpress:
I need to keep a history of posts (basically that's the only reason)
While I'm typing this, I'm thinking of a more integrated way of doingthis :)

what I want is:
  • Some static content.
  • Followed by some content that changes every month
  • Followed by a list of previous things
Example http://www.fps.net.nz
  • Intro bit
  • this month's give away
  • Previous give aways
Right now I do this with manual php (in header.php and footer.php) plus some calls to word press
PHP:
define('WP_USE_THEMES', false);
require_once('./wp/wp-blog-header.php');

// let's start by showing the "about" page

$args=array(
   'post_type'=>'page',
   'post__in' => array(27)
);
$my_query = new WP_Query($args);
while ($my_query->have_posts()): $my_query->the_post();
?>
<div class="sectionMain">
        <div class="titleBar">
                <h1><?php the_title(); ?></h1>
                <p id="pageDescription-<?php echo $post->ID; ?>"> &middot; What's all this FPS about then?</p>
        </div>
        <div class="pageNavLinkGroup"></div>
        <div class="blog-entry" id="blog-<?php echo $post->ID; ?>">
                <?php the_content(); ?>
        </div>
</div>
<?php
endwhile;
?>
etc ...

can I replicate this using a phpCallback on a page?
perhaps some thing like
PHP:
class FPS_HomePage_PageCallback_HomePage
{
        public static function response(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract $response)
        {
                $fps_intro = getSinglePost('My intro post');
                $fps_current_giveaway = getSinglePost('This Months Giveaway Post');
                $fps_previous_giveaway = getListOfThreadFromCategory(CategoryNumber);
                $response->params += array(
                        'FPS_intro' => $fps_intro,
                        'FPS_current_giveaway' => $fps_current_giveaway,
                        'FPS_previous_giveaway' => $fps_previous_giveaway
                );

        }
}

I'm about to give up on the wp integration as global constants, variables, and all sorts, start tripping over each other, this possible solution would give me a good result however.

presuamble once I've done this I could create a template, with a callback and use either xen:foreach (in the case of a list) or even xen:raw

any help very much appreciated.
 
bump?

I've watched the vids by Kier a couple of times, but I'm kinda stuck .. I need to know how I can extract a single post, or list from category before I can proceed
 
Haven't tested this...should work, or at least get you on the right path. The long and short of it is that you have to instantiate the model, and use that to get what you're looking for.

Within your callback method:

PHP:
//get our models
$postModel = $controller->getModelFromCache('XenForo_Model_Post');
$threadModel = $controller->getModelFromCache('XenForo_Model_Thread');

//grab the model
//each variable here is going to hold an array of information that can be passed to the template
$fps_intro = $postModel->getPostById(17); //post id for the post you want to use here...
$fps_current_giveaway = $postModel->getPostById(37); //ditto
$fps_previous_giveaway = $threadModel->getThreadsInForum(1); //forum id that holds the threads. There's also XenForo_Model_Thread::getThreadsByIds if that's what you're looking for

There are some additional fetch options you can add into the calls if you're looking for more information than what's within the basic query. You can check out XenForo_Model_Post and XenForo_Model_Thread for more.
 
old (hand coded bollocks, which is a nightmare after an upgrade) http://www.fps.net.nz/old.index.php

new home page with PHP callback and a single template: http://www.fps.net.nz/
data is retrieved from a single post, and a single forum.
The single post is in an "admins only forum" so can be tampered with, and the giveaways forum has "user can't create new threads" permissions.

I'm happy with it :) and should ber VERY happy with it come upgrade time
 
Top Bottom