Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » link the $Title of the page to another page on the site

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

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

Page: 1 2
Go to End
Author Topic: 2469 Views
  • shox
    Avatar
    Community Member
    21 Posts

    link the $Title of the page to another page on the site Link to this post

    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!

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: link the $Title of the page to another page on the site Link to this post

    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 %>?

  • shox
    Avatar
    Community Member
    21 Posts

    Re: link the $Title of the page to another page on the site Link to this post

    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??

  • SImoX
    Avatar
    Community Member
    11 Posts

    Re: link the $Title of the page to another page on the site Link to this post

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

  • shox
    Avatar
    Community Member
    21 Posts

    Re: link the $Title of the page to another page on the site Link to this post

    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?? :/

  • SalvaStripe
    Avatar
    Community Member
    89 Posts

    Re: link the $Title of the page to another page on the site Link to this post

    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.

  • shox
    Avatar
    Community Member
    21 Posts

    Re: link the $Title of the page to another page on the site Link to this post

    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.

  • SalvaStripe
    Avatar
    Community Member
    89 Posts

    Re: link the $Title of the page to another page on the site Link to this post

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

    2469 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.