Manfred62 Posted February 13, 2013 Share Posted February 13, 2013 simple question: how to link to a side, which is not shown in the navigation, but in footer. Page 'disclaimer' is in the tree under root, is hidden, but published. Normally I woud do it this way: <a href="../disclaimer">Disclaimer</a> but under the home (root) the url points one step higher. Didn't found any tutorial, cheatsheets are a big collection of developer/guru speaking, search in forum not helpful.. Is that so difficult?? Link to comment Share on other sites More sharing options...
diogo Posted February 13, 2013 Share Posted February 13, 2013 Not difficult at all. The way you are doing it, the two dots are pointing one directory up, wish means that the browser is looking for a page that is at the same level then root. If you would do this for example: <a href="/disclaimer">Disclaimer</a> ...it would work on the root, but not on the other pages. To fix it, you have two options. On a non dynamic site, the option would be having an absolute link instead of a relative link: <a href="http://www.yoursite.com/disclaimer">Disclaimer</a> In PW you can do something that will allow you to change the domain of the website without breaking the link: <a href="<?= $pages->get('/disclaimer/')->url ?>">Disclaimer</a> edit: see soma's correction below for a more correct and accurate answer ↴ Link to comment Share on other sites More sharing options...
Soma Posted February 13, 2013 Share Posted February 13, 2013 Not difficult at all. The way you are doing it, the two dots are pointing one directory up, wish means that the browser is looking for a page that is at the same level then root. If you would do this for example: <a href="/disclaimer">Disclaimer</a> ...it would work on the root, but not on the other pages. To fix it, you have two options. On a non dynamic site, the option would be having an absolute link instead of a relative link: Sorry to correct you here diogo, but <a href="/disclaimer">Disclaimer</a> works for all levels as it's absolute starting from "/" root. Still better in PW is <a href="/disclaimer/">Disclaimer</a> as it would do a redirect to add trailing slash which is default in PW. You could also use id of the page, so even if you move the page it still get's the right url to the page. <a href="<?= $pages->get(1023)->url ?>">Disclaimer</a> Link to comment Share on other sites More sharing options...
Manfred62 Posted February 13, 2013 Author Share Posted February 13, 2013 thanks diogo/soma hmm ok, I missed the ->url <a href="<?= $pages->get('/disclaimer/')->url ?>">Disclaimer</a> think, PW could get more fresh users with better helpful documentations in practical context. Link to comment Share on other sites More sharing options...
Soma Posted February 13, 2013 Share Posted February 13, 2013 http://processwire.com/api/cheatsheet/#page 5th entry in that list. $page->url is something so basic and covered all over the place on processwire.com. It's all under API, as it's the only thing you need to know to build templates/pages http://processwire.com/api/what/ http://processwire.com/api/templates/ http://processwire.com/api/variables/page/ http://processwire.com/tutorials/quick-start/navigation/ Or of course http://wiki.processwire.com/index.php/Main_Page. If not, there's even a basic site when you install PW which also is something you want to study first when starting with PW and come ask question if you don't understand something here. I think that's quite good and there's many people think PW has exceptional documentation for a OS project. For some strange reason we still have to figure out why some people think the opposite. There's also the forum which has tons of examples (might use google search to search) and simple questions get answered here mostly immediately. 3 Link to comment Share on other sites More sharing options...
arjen Posted February 14, 2013 Share Posted February 14, 2013 I think that's quite good and there's many people think PW has exceptional documentation for a OS project. For some strange reason we still have to figure out why some people think the opposite. This is absolutely true. I think most people just want to do their own stuff - which is totally understandable. But it would be better to study the planets, Joss, blog profile, skyscrapers profile and created the first site afterwards. One thing I had a hard time understanding is the modal stuff like $this->that->image->url. Those things are difficult to cover in any tutorial, but my experience is that you have to read between the lines. And suddenly you know it when you understand it. Link to comment Share on other sites More sharing options...
diogo Posted February 14, 2013 Share Posted February 14, 2013 Sorry to correct you here diogo Thanks for correcting me soma. That was a basic error, I should be more careful. There's also the forum which has tons of examples (might use google search to search) shouldn't we make it obvious and just implement google search alongside the forum search? 1 Link to comment Share on other sites More sharing options...
Wanze Posted February 14, 2013 Share Posted February 14, 2013 +1 for Google search as addition to the forum search. I almost never find the thread or the answers searching for with the internal search Link to comment Share on other sites More sharing options...
Luis Posted February 14, 2013 Share Posted February 14, 2013 Yes please, give new search and a WillyC translat0r too Link to comment Share on other sites More sharing options...
ryan Posted February 15, 2013 Share Posted February 15, 2013 Mostly repeating what's already been said. But if that disclaimer page is always going to be off the root, regardless of whether on your development or production server, the I would just do this: <a href='/disclaimer/'>Disclaimer</a> If the site may move around from one subdirectory to another (like between development and production, as is the case for me), then I'd do this: <a href='<?=$config->urls->root?>disclaimer/'>Disclaimer</a> If you want to account for the possibility that the disclaimer page may move, then you'd do this (where 123 is the ID of the disclaimer page): <a href='<?=$pages->get(123)->url?>'>Disclaimer</a> Though note that you are then talking about more overhead in this last example, relative to the first two. So it's rare that I do this, unless it's a page that needs to move often (don't think I've run into that situation). 1 Link to comment Share on other sites More sharing options...
Manfred62 Posted February 15, 2013 Author Share Posted February 15, 2013 Ryan, thanks for the infos. I've taken the ID solution. Playing around with a local testpage. Still have to learn a lot... Link to comment Share on other sites More sharing options...
joer80 Posted May 28, 2014 Share Posted May 28, 2014 Since I would think it would add a db query every time you look up a page id, I think I am going to do the $config->urls->root method in most cases as well! 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