Jump to:

5554 Posts in 1742 Topics by 1227 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Mulitple Article Holder Pages

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1694 Views
  • innyinskip
    Avatar
    Community Member
    46 Posts

    Mulitple Article Holder Pages Link to this post

    Hi Chaps,

    Ive been following the tutorial here: http://doc.silverstripe.org/tutorial:2-extending-a-basic-site for creating an article system
    which has been great. Got it working and very happy.

    Ive then gone on to add the homepage controller which will show the 'Latest news' from the article page holder.
    Which again has worked great.

    My question is:
    If i was to create 2 or more article holders with their article pages, could i like them both to work within the 'latest news' function?

    EG:

    IT News
    ---------> HomePage displaying the 5 latest news posts from both article holders?
    HR News

    HomePage.php
    ---------------------------------------------------------------
    <?php
    /**
    * Defines the HomePage page type
    */
    class HomePage extends Page {
    static $db = array(
    );
    static $has_one = array(
    );
    }

    class HomePage_Controller extends Page_Controller {

    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

    }

    ?>

    --------------------------------------------------------------------------------
    ArticleHolder.php
    ---------------------------------------------------------------------------------

    <?php
    /**
    * Defines the ArticleHolder page type
    */
    class ArticleHolder extends Page {
    static $db = array(
    );
    static $has_one = array(
    );

    static $allowed_children = array('ArticlePage');
    }

    class ArticleHolder_Controller extends Page_Controller {

    }

    ?>

    I know this is a bit complicated but if someone could point me in the right direction i would be VERY graeteful!
    Many Thanks
    Craig

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Mulitple Article Holder Pages Link to this post

    Well this is actually quite simple. If you look at the following function from that tutorial

    function LatestNews($num=5) {
    $news = DataObject::get_one("ArticleHolder");
    return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
    }

    This simply says get the children on 1 holder. If you have multiple holders you could make the function look like:

    function LatestNews($num=5) {
    return DataObject::get("ArticlePage", "", "Date DESC", "", $num);
    }

  • innyinskip
    Avatar
    Community Member
    46 Posts

    Re: Mulitple Article Holder Pages Link to this post

    Will you truley are a legend.

    Thanks very much!
    Now just to have in in a section and scrolling mwah!!

    Thanks again mate!

  • innyinskip
    Avatar
    Community Member
    46 Posts

    Re: Mulitple Article Holder Pages Link to this post

    Will,

    Forgive me for being thick, but im wanting to have this as a small box at the bottom of the homepage scrolling up. V similar to this: http://www.yellowbrickroadconsulting.co.uk/

    But rather than a widget more as a kind of footer scrolling up with the latest 4 or 5 posts.

    Is that at all possible. Im havnig real issues even resizing it at the moment. Whatever i enter into the CSS its not resizing. Is it because of the type of control it is that it wont go smaller? (height wise?)
    Many Thanks
    Craig

  • Willr
    Avatar
    Forum Moderator
    5511 Posts

    Re: Mulitple Article Holder Pages Link to this post

    You probably need to make that div a set height then also need to set the overflow css property to hidden. Getting it to auto scroll you probably want to use jQuery to animate it.

  • innyinskip
    Avatar
    Community Member
    46 Posts

    Re: Mulitple Article Holder Pages Link to this post

    Hi Will, Thanks for that.

    I have managed to redesign it and get it the way i want but am having some major head issues with the jQuery.

    From what i understand...

    the JS files would have to be set in the 'Homepage.php' within the controller.
    This is fine but i have also seen that this is required:

    $('.myclass').vTicker({
    speed: 500,
    pause: 3000,
    showItems: 3,
    animation: 'fade',
    mousePause: false,
    height: 0,
    direction: 'up'
    });

    Im not entierly sure where this would go. I have tried both in the template file and the page controller but nothing.
    The ticker im trying to use is here:

    http://www.jugbit.com/jquery-vticker-vertical-news-ticker/

    Can you point me in the right direction please mate?

    Thank you very much

    Craig

  • innyinskip
    Avatar
    Community Member
    46 Posts

    Re: Mulitple Article Holder Pages Link to this post

    Not to worry, ive been playing about all day and FINALLY managed it!
    (not the easiest task)

    Last slight issue..

    After doing all this all my current news pages seem to be invalid links.
    New pages i create work but the ones previously dont...

    I cant unpublish them in the cms they just give me a server error.
    Is there a way to 'clean' items from the cms?

    Thanks

    1694 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.