Show all page with he same type page in other page

silverstripe-4
Tags: #<Tag:0x00007f10c9374188>

#1

Silverstripe Version:
4.0.2
Question:

Hi I have page with Product and I show All products in bottom of page here:
http://www.nerezove-zabradlie-a-schody.sk/zabradlia/interierove-zabradlia/

class ItemPage_Controller extends PageController {
    public function LatestArticles($count = 4)
    {
        return ItemPage::get()
            ->sort('Created', 'ASC')
            ->limit($count);
    }
}
<% loop $LatestArticles %>	
    <div class="grid-item col-md-4">
        <div><img class="img-fluid" src="$Ilustracny.Link" /></div>						
        <div class="text">
            <h3>$Title</h3>
            <p>$Popis</p>
            <a href="$Link" style="width: 180px;" class="btn btn-primary btn-orange-white">Zistiť viac</a>
        </div>
    </div>
<% end_loop %>

But I want show only other products… something like: if Title != This Page Title


#2

Hi @Zuzka_Simova , welcome to the forum! Try this:

return ItemPage::get()
    ->sort('Created', 'ASC')
    ->limit($count)
    ->exclude('ID', $this->ID);

p.s. I tidied up the code in your post a bit so it gets formatted nicely. For future reference you can use markdown formatting to indicate code blocks, or you can select your code and click the code button. If you click Edit on your original post you can see the markdown formatting I used as an example.


#3

Thank you very much :slight_smile: