Jump to content

How can I add a link to a Custom text


mosravo
 Share

Recommended Posts

http://processwire.com/api/variables/pages/

Find all skyscrapers (i.e. pages using the skyscraper template). Then make a list linking to each of them. Note that this foreach() example below also applies to all examples below this – the foreach() has been left out of later examples for brevity.
  • $skyscrapers = $pages->find("template=skyscraper");
    foreach($skyscrapers as $s)    echo "<li><a href='{$s->url}'>{$s->title}</a></li>";
  • Like 1
Link to comment
Share on other sites

The easiest way to link to one specific page would be by ignoring PW entirely and just typing href="/service/" in your template file. Slightly more complex, but giving you powerful advantages would be to grab the page with $pages->get(). You can pass the get function either the page's path as above, or its numeric ID, or a full blown selector string. Then you can use ->url on the resulting page object. At first sight this may seem like an overcomplication when you can just link to the path, but since it gives you the full page, you can make your link text multilingual or display whatever fields alingside it.

  • Like 1
Link to comment
Share on other sites

http://processwire.com/api/variables/pages/

  • $skyscrapers = $pages->find("template=skyscraper");
    foreach($skyscrapers as $s)    echo "<li><a href='{$s->url}'>{$s->title}</a></li>";
kongondo thank you, this method work for the subpages i created, what i actually want is the main page to link not the subpages, or is it only subpages that we can link?
Link to comment
Share on other sites

thanks, for your tips. i have arrived at the answer with this

<?php
  $s = $pages->get("/service/");
  echo "<li><a href='{$s->url}'>{$s->title}</a></li>"; 
?>
  

thanks.Kongondo and Jan Romero .Jan your method work too. you can see what i was able to achieve with it at www.mcalleluyashow.mil.nf though i am still working on the the slide show i am trying to still implement.

Thanks once again for your support

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...