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   2007 Views

Avatar
lusiton

13 Posts

8 November 2007 at 12:37pm

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

Core Development Team, 201 Posts

8 November 2007 at 1:16pm

Edited: 08/11/2007 1:20pm

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

13 Posts

8 November 2007 at 1:26pm

Hi Tim.

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

Thank you.

Avatar
lusiton

13 Posts

8 November 2007 at 5:31pm

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

Forum Moderator, 5513 Posts

8 November 2007 at 6:20pm

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

Avatar
lusiton

13 Posts

9 November 2007 at 1:09am

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.