Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

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

[SOLVED] Article holder not displaying on the page


Go to End


23 Posts   4068 Views

Avatar
buffy999

Community Member, 18 Posts

28 July 2014 at 8:57pm

Edited: 04/08/2014 8:38pm

Hi,

I need help with trying to get the news items on the Article Holder page to show up. Been trying to get it to work for weeks.

Any help would be greatly appreciated. :D

http://www.teachsign.org.nz/
http://www.teachsign.org.nz/about-teachsign/updates

Here's the codes...

ArticleHolder.php:

<?php
class ArticleHolder extends Page {

	static $db = array(
	);
	static $has_one = array(
	); 
	
    static $allowed_children = array('ArticlePage');
    
    private static $icon = "cms/images/treeicons/news.png";
    
}
class ArticleHolder_Controller extends Page_Controller {
}

ArticleHolder.ss:

<% include SideBar %>
<div class="content-container unit size3of4 lastUnit pages" id="article-page">
    <% include BreadcrumbNavigationTemplateAllLinked %>  
    <div class="top-icon"><img src="{$ThemeDir}/images/page-icon-top.png" /></div>
    <article>
        <h1>$Title</h1>
        <div class="content">$Content</div>
    <% loop $Children %>
        <article>
             <h2><a href="$Link" title="Read more on &quot;{$Title}&quot;">$Title</a></h2>
	     <p class="newsDateTitle">$Date.Nice</p>
            <p>$Content.FirstParagraph<span>...</span></p>
       </article>
    <% end_loop %>
    $Form
    </article>
</div>

ArticlePage.php:

<?php
class ArticlePage extends Page {
	private static $db = array(
        'Date' => 'Date',
        'Author' => 'Text'
    );
    
    public function getCMSFields() {
    	$fields = parent::getCMSFields();
     
    	$dateField = new DateField('Date', 'Article Date (for example: 20/12/2010)');
    	$dateField->setConfig('showcalendar', true);
    	$dateField->setConfig('dateformat', 'dd/MM/YYYY');
             
    	$fields->addFieldToTab('Root.Main', $dateField, 'Content');
    	$fields->addFieldToTab('Root.Main', new TextField('Author', 'Author Name'), 'Content');
 
    	return $fields;
	}
	
	private static $icon = "cms/images/treeicons/news-listing.png";
	
}
class ArticlePage_Controller extends Page_Controller {
}

ArticlePage.ss:

<div class="content-container unit size3of4 lastUnit pages" id="article-page">
    <% include BreadcrumbNavigationTemplateAllLinked %>
    <div class="top-icon"><img src="{$ThemeDir}/images/page-icon-top.png" /></div>
    <article>
        <h1>$Title</h1>
        <div class="news-details">
            <p>Posted on $Date.Nice<!--by $Author--></p>
        </div>
        <div class="content">$Content</div>
    </article>
    $Form
</div>

HomePage.php:

class HomePage_Controller extends Page_Controller {
	public function LatestNews($num=4) {
    	$holder = ArticleHolder::get()->First();
    	return ($holder) ? ArticlePage::get()->filter('ParentID', $holder->ID)->sort('Date DESC')->limit($num) : false;
	}
}

Avatar
Kirk

Community Member, 67 Posts

30 July 2014 at 2:31pm

I see in the ArticleHolder.ss template you have a include called ArticleTeaser inside the Children loop.

I can not see a ArticleTeaser template include in the example code you have supplied does this need to be created?

Also a good tip would be to place $Debug inside the ArticleHolder.ss Children loop and it will spit out all useful debugging info (remember to take it out though)
The $Debug template variable is referenced in the Debugging techniques on http://doc.silverstripe.org/framework/en/topics/debugging

Avatar
geekdenz

Community Member, 37 Posts

3 August 2014 at 11:19pm

Agree, it must be the missing ArticleTeaser included.

Why don't you just simplify and not use the teaser include:
http://www.sspaste.com/paste/show/53de1656314ae

Avatar
buffy999

Community Member, 18 Posts

4 August 2014 at 8:11pm

Hi Kirk and Geekdenz,

Yeah you are right, i forgot to include the ArticleTeaser.ss into the post, i've updated my first post here.

I'll give it a try and remove the include and just add into the ArticleHolder.ss instead. Will let you know how it go. :)

Thanks.

Avatar
buffy999

Community Member, 18 Posts

4 August 2014 at 8:41pm

Hi guys,

i've changed the ArticleHolder.ss code to remove the ArticleTeaser.ss, but still no change on the page at all:
http://www.teachsign.org.nz/about-teachsign/updates

I've upload it and used the dev/build, still no result. Any ideas?

Thanks. :)

Avatar
geekdenz

Community Member, 37 Posts

4 August 2014 at 10:59pm

Did you try http://www.teachsign.org.nz/about-teachsign/updates?flush=all ?

When changing templates you need to flush the cache.

Avatar
buffy999

Community Member, 18 Posts

5 August 2014 at 2:40pm

Yes i did, still no change at all though. Maybe it the code that is not right??

Avatar
geekdenz

Community Member, 37 Posts

5 August 2014 at 5:42pm

Can you please post the relevant code on http://www.sspaste.com/ . I find it hard to read the code posted in this forum.

Go to Top