mosravo Posted June 18, 2014 Share Posted June 18, 2014 I want to add a link to a text to my custom page, how can i do that? assuming in my custom nav i have services i want to link it, how can i do that t in processwire to link it to the service page Link to comment Share on other sites More sharing options...
kongondo Posted June 18, 2014 Share Posted June 18, 2014 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>"; 1 Link to comment Share on other sites More sharing options...
Jan Romero Posted June 18, 2014 Share Posted June 18, 2014 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. 1 Link to comment Share on other sites More sharing options...
mosravo Posted June 19, 2014 Author Share Posted June 19, 2014 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 More sharing options...
mosravo Posted June 19, 2014 Author Share Posted June 19, 2014 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now