Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

17478 Posts in 4473 Topics by 1972 members

Archive

SilverStripe Forums » Archive » 0,1 and more comment/s

Our old forums are still available as a read-only archive.

Page: 1
Go to End
Author Topic: 0,1 and more comment/s 377 Views
  • typopunk
    avatar
    Community Member
    6 posts

    0,1 and more comment/s Link to this post

    Hello

    I just set up an Article Section (holder and page) as decribed in tutorial 2. In addition I now want to display "no comments", "1 comment" or "x comments" - depending on the number of comments.

    On the individual page of an article I managed to do so via this setup:

    ArticlePage.ss

    $Content
    <% if Comments.Count %>
    $Comments.Count
    comment<% if hasManyComments %>s<% end_if %>
    <% else %>
    no comments
    <% end_if %>

    ArticlePage.php

    class ArticlePage_Controller extends Page_Controller {
    function hasManyComments() {
    $comments = $this->Comments();
    $ccounter = $comments->Count();
    if ($ccounter>1) return true; else return false;
    }
    }

    On the page this does a good job but it doesn't seem to work inside the <% control Children %> loop of the article holder. The "if Comments.Count" part seems to work but my additional function "hasManyComments" fails. I'm sure that my function needs to look different in that case but I can not find out how...

    I'd be happy if someone could lead me to the right direction. Thanks in advance.

    EDIT: I finally solved the problem on my own - no support needed anymore.

    377 Views
Page: 1
Go to Top

Currently Online: wildflower1975, Eco

Welcome to our latest member: Eco

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

Comments on this website? Please give feedback.