17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2355 Views |
-
Take content from other pages

4 September 2008 at 5:58pm
Is there a way to take content from other pages?
(in Page.ss)
$Page(Blog).Contentor something like that?
If there is a way to do that, is there a way to show only like the first 3 posts?
$Page(Blog).Content(3)What I am trying to do, is be able to include content from multiple pages and show that content through Page.ss.
-
Re: Take content from other pages

4 September 2008 at 6:22pm Last edited: 4 September 2008 6:22pm
You can try these:
$ChildrenOf(url-segment).Content
As for limiting post count inside the template, the only way im aware of is:
$ChildrenOf(blog-url-segment).Iterator.Offset(0)
$ChildrenOf(blog-url-segment).Iterator.Offset(1)
$ChildrenOf(blog-url-segment).Iterator.Offset(2)or
$ChildrenOf(blog-url-segment).Range(0, 3)
but im not sure if the second one will work in a <% control %> block.
-
Re: Take content from other pages

4 September 2008 at 6:30pm Last edited: 4 September 2008 6:34pm
I can't get these to work like I was hoping to.
When I use any of those, it just places a link.
Example...
$ChildrenOf(Blog).Content
This will add links to the blog posts.
(here is what the html looks like.)<ul id="Menu1">
<li onclick="location.href = this.getElementsByTagName('a')[0].href"><a href="">SilverStripe blog module successfully installed</a></li>
</ul>
.ContentIs the syntax different?
**edit**
<% control ChildrenOf(Blog) %>
$Content
<% end_control %>This works
-
Re: Take content from other pages

4 September 2008 at 6:34pm
My first snippet was stuffed up a bit - i just realised it would have to be nested inside a control as well.
As for the snippet you posted, are you trying to achieve something like:
<ul id="Menu1">
<% control ChildrenOf(blog) %>
<li><a href="$Link">$Title</a> - $Content.FirstParagraph</li>
</ul>
<% end_control %> -
Re: Take content from other pages

4 September 2008 at 6:36pm Last edited: 4 September 2008 6:53pm
That code snippit was what
$ChildrenOf(Blog).Content
output (no <% control %>) just that line by itself.
This does work though
<% control ChildrenOf(Blog) %>
$Content
<% end_control %>By the way, Thank you
You punted me in the right direction.
--------------
I still need to figure out somehow to limit it.
lets say, I only need the first 4 images from the gallery page.
Here are some things Ive tried.
ChildrenOf(gallery).Iterator.Offset(2)
ChildrenOf(gallery).Range(0, 3)
ChildrenOf(gallery)(2)
ChildrenOf(gallery).(2) -
Re: Take content from other pages

4 September 2008 at 8:39pm Last edited: 4 September 2008 8:39pm
Hi again grilldan,
I think the problem is that currently <% control Something.SomethingElse(x) %> isn't supported. However, you can always use something like:
<% control ChildrenOf(blog) %>
<% control Range(0,3) %>
$Content
<% end_control %>
<% end_control %>
| 2355 Views | ||
|
Page:
1
|
Go to Top |


