Skip to content

@jbrooksuk /gist:86ca87b92c56b2cd7221 secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ArticleContent
<?php
$AC = new articleContent();
class articleContent {
public $current_article = 0;
public $article_count = 0;
protected $in_the_loop = false;
public $articles = array();
public $article = array();
function __construct() {
global $dbDriver;
/* Article Data */
$articleQuery = $dbDriver->query("SELECT p.*, a.*, (SELECT COALESCE(COUNT(m_article_id), 0) FROM xc_meta m WHERE m.m_article_id = a._article_id) AS widgetCount FROM xc_page AS p LEFT JOIN xc_articles AS a ON p._page_id = a.a_page_id WHERE p._page_id=1 ORDER BY a.a_section_id, a.a_order_id");
$this->article_count = $articleQuery->num_rows;
while ($aRow = $dbDriver->fetch('assoc', $articleQuery)) {
$this->articles[] = $aRow;
}
}
function next_article() {
$this->current_article++;
$this->article = $this->articles[$this->current_article];
return $this->article;
}
function the_article() {
$this->in_the_loop = true;
if($this->current_article == 0) add_action('loop_start');
$this->article = $this->next_article();
}
public function have_articles() {
if($this->current_article + 1 <= $this->article_count) {
return true;
}
$this->in_the_loop = false;
return false;
}
public function __get($io) {
echo "<pre>" . print_r($this->articles[$this->current_article], true) . "</pre>";
return $this->articles[$this->current_article][$io];
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.