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.

Archive

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

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

Latest titles from blog section to appear in blog div on template


Reply

6 Posts   1989 Views

Avatar
lusiton

8 November 2007 at 12:37pm 13 Posts

Hello Guys.
I previously used CMS system called Mephisto that run on Ruby on Rails. I'm looking for similar functions with SS and not sure I can figure it out. What I need is:
Latest article titles from section to appear on the template in separate div. For instance three latest titles from the blog section to appear in blog div on template.
I'm sure there is a way to do it. I'm just stupid and can't figure it.

Thank you in advance.

Avatar
Tim

8 November 2007 at 1:16pm (Last edited: 8 November 2007 1:20pm), Core Development Team, 201 Posts

Tutorial two will take you through doing this, however as a really simple example on how to do this you could use

<% control ChildrenOf(latest-news) %>

<h2>$Title</h2>
$Content.LimitWordCount(50)
<a href=$Link> more </a>

<% end_control %>

This would assume you have a page with the URL "latest-news", and you want to loop though all it's children, display a summary of the first 50 words, and then provide a link to the main article.

Just put this code anywhere in your tempalte

Avatar
lusiton

8 November 2007 at 1:26pm 13 Posts

Hi Tim.

I appreciate your help on this.
I'm going to try it.

Thank you.

Avatar
lusiton

8 November 2007 at 5:31pm 13 Posts

I got it working. Now I'm trying to figure out to do the same with the blog page so it will display few of the blog children. This is what I came up with:

<div id="blog">
<% if blog %>
<p class="ChildrenOf(blog)">
<% $Content.LimitWordCount(20) %>
<h3>$Title</h3>
<a href="$Link"> more </a></p>
<% end_if %>
</div>

So far no luck but probably I'm doing something wrong again. Also some how I want to limit the number of children instances on the page. If you have ideas it would be great. I'm trying to learn from my mistakes.

Avatar
Willr

8 November 2007 at 6:20pm Forum Moderator, 5511 Posts

if you are on the blog page template and want to control its children you can just use <% control Children %>

Avatar
lusiton

9 November 2007 at 1:09am 13 Posts

Hello Willr.

Thank you for responding to my post.
So far I have single template to accommodate my website and I'm not sure hot to add a separate template for particular section. In the main content section I have this code:
$Content $Form $PageComments. If I will add this code <% control Children %> as you suggested it will control children of all sections unless it is on the separate template. It would be great if you could suggest how to assign a separate template to a section.

Thank you in advance.