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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

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

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

link the $Title of the page to another page on the site


Go to End


11 Posts   5123 Views

Avatar
shox

Community Member, 21 Posts

10 December 2008 at 10:35am

Hey all,
i ran across a problem. here is my situation.
On the homepage im displaying 5 children pages.
now what i want is that the title of these children pages will redirect to another page on the site.
for example:
<a href="$link">$Title</a> <!-- This will redirect to another page on the site-->
$content <!-- this is the content of the active page atm-->

does this make any sense??
thanks!

Avatar
Liam

Community Member, 470 Posts

10 December 2008 at 3:53pm

I'm a little confused.

You just want to link to each child page? Why can't you just put that code in your control in your template?

How are you currently listing the 5 child pages? Are you using a custom php function like in the tutorials, or are you using a regular <% control Children %>?

Avatar
shox

Community Member, 21 Posts

10 December 2008 at 7:23pm

Ill try to make it a bit more clear.
My homepage contains a <%control childrenof(page) %> which has 5 children. These 5 children are listed . What i want is that each $title of these 5 children will be a link, which will point to another 5 children of another sibling.

Home
page 1
child 1 of page 1
child 2 of page 1
child 3 of page 1
page 2
child 1 of page 2
child 2 of page 2
child 3 of page 2

So basically i want the $title of "child of page 1" to link to "child 1 of page 2", "child 2 of page 2" linking with "child 2 of page 2" etc.

Is it more clear now??

Avatar
SImoX

Community Member, 11 Posts

10 December 2008 at 11:42pm

<ul>
<% control Children %>
<li><a href="$Link">$Title</a></li>
<% end_control %>
</ul>

Avatar
shox

Community Member, 21 Posts

11 December 2008 at 12:33am

hi SImoX. the problem with that code is that it controls the children of page 1.

i know its a bit complicated so let me try again.
page home shows the items of page 1 <%control childrenof(page1) %>
now what i want is that the title of the posts that get listed from the children of page1 become the links to the children of another page on the site, page2.

clear?? :/

Avatar
SalvaStripe

Community Member, 89 Posts

11 December 2008 at 3:31am

Edited: 11/12/2008 3:34am

do you have very many posts listed with <%control childrenof(page1) %> ???
you could use

<ul>
<li><a href="<% if Title = page1child1 %><% control Page(page2child1) %>$Link<% end_control %><% end_if %><% if Title = page1child2 %><% control Page(page2child2) %>$Link<% end_control %><% end_if %><% if Title = page1child3 %><% control Page(page2child3) %>$Link<% end_control %><% end_if %>">$Title</a></li>
</ul>

Its very hard coded but for 5 children Link to other 5 children you could use such a code.

Avatar
shox

Community Member, 21 Posts

11 December 2008 at 4:28am

they are not that many (round 5 or 6 eventually).
your method sounds good for now. Though if anyone can think of an automatic way of doing this im all ears.

Thanks SalvaStripe.

Avatar
SalvaStripe

Community Member, 89 Posts

11 December 2008 at 4:57am

i will think about it! the automatic way is just my favourit way too ;)

Go to Top