ankh2054 Posted April 21, 2014 Share Posted April 21, 2014 Hi All, I really seem to be struggling with the syntax of process wire, could anyone point me in the right directoin of some good documents or tutorials to read. I am trying to link back to my homepage / via the below and can't get it to work. <a class="navbar-brand" href="<?php echo $pages->get('/') ?>"><?php echo $pages->get("/site-settings/")->site_title; ?></a> What does everyone else use to go back to the root URL? thanks Link to comment Share on other sites More sharing options...
ankh2054 Posted April 21, 2014 Author Share Posted April 21, 2014 Not sure why and how, but I seem to have tried href="/" and now it works. Must not of uploaded changes. oops. Any documentation of syntax would really help me. As a non PHP coder, I struggle to understand when to use <?php , {, ", ', etc.... thank Link to comment Share on other sites More sharing options...
marcus Posted April 21, 2014 Share Posted April 21, 2014 $pages->get('/') just returns the ID of the home page. Try $pages->get('/')->url 2 Link to comment Share on other sites More sharing options...
netcarver Posted April 21, 2014 Share Posted April 21, 2014 If you are new to PHP then you might find the resources at php.net really useful. There's documentation for the entire language including every function. 3 Link to comment Share on other sites More sharing options...
kongondo Posted April 21, 2014 Share Posted April 21, 2014 These three are a must read in order to use PW $page: http://processwire.com/api/variables/page/ $pages: http://processwire.com/api/variables/pages/ Selectors: http://processwire.com/api/selectors/ Btw (sorry to be pedantic!) ProcessWire really does not have a syntax (in the sense of MODx syntax, for example). It's all PHP 2 Link to comment Share on other sites More sharing options...
ankh2054 Posted April 21, 2014 Author Share Posted April 21, 2014 thanks all for being so patient Could someone help me with the below, I am trying to show the name of the current logged in user. <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php $user->name; ?><b class="caret"></b></a> Link to comment Share on other sites More sharing options...
marcus Posted April 21, 2014 Share Posted April 21, 2014 Seems that only an echo is missing, <?php echo $user->name; ?> 1 Link to comment Share on other sites More sharing options...
ankh2054 Posted April 21, 2014 Author Share Posted April 21, 2014 thanks that worked Just leaving my code, for other people who might struggle like me <?php if($user->isLoggedin()): ?> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"><?php echo $user->name; ?><b class="caret"></b></a> <ul class="dropdown-menu"> <li><a href="[[~12]]"><i class="icon-user"></i> My Account</a></li> <li><a href="[[~12]]"><i class="icon-envelope"></i> Inbox <span class="badge badge-info"></span></a></li> <li class="divider"></li> <li><a href="?logout=1" title="Logout"><i class="icon-off"></i> Logout</a></li> </ul> </il> <?php else: ?> <li><a href="/register/">Sign up</a></li> <li><a href="/login/">Login</a></li> <?php endif; ?> Link to comment Share on other sites More sharing options...
Nico Knoll Posted April 21, 2014 Share Posted April 21, 2014 Another way to get the homepage url ("root url") is: <?php echo $config->urls->root; ?> Link to comment Share on other sites More sharing options...
kongondo Posted April 21, 2014 Share Posted April 21, 2014 @Charles....I see some MODx code left in there: [[~12]]. Won't output anything in PW . You need something like echo $page->url; 1 Link to comment Share on other sites More sharing options...
ankh2054 Posted April 22, 2014 Author Share Posted April 22, 2014 haha yes indeed, don't have those pages ready 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