[campsite-dev] Best way to get names of articles, names of publications, etc
  • Hi Mugur,

    I'm working on a quick API to campsite the will fetch article titles,
    sections titles, etc from the database, give the IDs for same. I need
    this for my stats thing, since I'm trying to design it so that the stats
    engine can be mounted on a separate system. Originally I thought I'd
    just pull the data out of the database directly. But then I though I
    might be able to do that using your DatabaseObject class. Is there an
    efficient way for example to get *all* article titles for a given issue
    of a given publication using this approach? Or is the direct database
    approach still the best/simplest?

    JP
  • 1 Comment sorted by
  • To pull out articles, you can use this static function from the Article
    class:

    function GetArticles($p_publicationId = null,
    $p_issueId = null,
    $p_sectionId = null,
    $p_languageId = null,
    $p_articleId = null,
    $p_preferredLanguage = null,
    $p_numRows = null,
    $p_startAt = '',
    $p_numRowsIsUniqueRows = false)

    This will return to you an array of Article objects. You have the
    option of specifying as many or as few of the parameters as you want.
    Look at the classes/Article.php file for the full documentation. A
    quick example: print the article titles in the issue with ID 1,
    publication ID 2:

    $articles =& Article::GetArticles(2, 1);
    foreach ($articles as $article) {
    echo $article->getTitle()."
    ";
    }

    To retrieve Sections (from Section.php):

    function GetSections($p_publicationId = null,
    $p_issueId = null,
    $p_languageId = null,
    $p_sqlOptions = null)

    Also a static function, same sort of functionality - this will return to
    you an array of Section objects.

    For Issues (from Issue.php):

    function GetIssues($p_publicationId = null,
    $p_languageId = null,
    $p_issueId = null,
    $p_preferredLanguage = null,
    $p_sqlOptions = null)

    Same as above.

    The publication class wasnt very developed in 2.3, in 2.4 it has the
    same functionality. You'll notice that the Article::GetArticles() does
    not use the $sqlOptions argument. This will probably change in 2.4.

    - Paul


    John Pye wrote:
    > Hi Mugur,
    >
    > I'm working on a quick API to campsite the will fetch article titles,
    > sections titles, etc from the database, give the IDs for same. I need
    > this for my stats thing, since I'm trying to design it so that the stats
    > engine can be mounted on a separate system. Originally I thought I'd
    > just pull the data out of the database directly. But then I though I
    > might be able to do that using your DatabaseObject class. Is there an
    > efficient way for example to get *all* article titles for a given issue
    > of a given publication using this approach? Or is the direct database
    > approach still the best/simplest?
    >
    > JP
    >