Godfrey Posted July 24, 2013 Share Posted July 24, 2013 I'm trying to get a page url and echo it in a link, however I keep getting error: Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in C:\wamp\www\klp\wire\core\Selectors.php line 165) I have tried two methods: <a href='<?php $pages->get("gallery")->url; ?>'> Back </a> <?php echo ' <a href=" '.$pages->get('gallery')->url.' "> Back </a>';?> But both are getting me the same result. Sometimes half my page just doesn't even load. I read around and think I need to escape my quotations. I have no idea what I would escape in this case though.... I think the key problem here is the double quotes while trying to select gallery ("gallery"), because when I am doing this without having to use the get() method it works perfectly. (e.g. $page->$albumimage->url; works for me) What would I escape to get this properly working? Link to comment Share on other sites More sharing options...
arjen Posted July 24, 2013 Share Posted July 24, 2013 I don't think "gallery" is a proper selector. Either you use /gallery/ or something like template=gallery. $pages->get('/gallery/')->url; $pages->find('template=gallery')->url; Does $page->$albumimage->url really work? Shouldn't this be $page->albumimage->url? 3 Link to comment Share on other sites More sharing options...
teppo Posted July 24, 2013 Share Posted July 24, 2013 (edited) What @arjen said + your first example doesn't really do anything: <a href='<?php $pages->get("/gallery/")->url; ?>'> Back </a> Second example is OK (except for the non-working selector), but what you probably meant to do in your first example was one of these: <a href='<?php echo $pages->get("/gallery/")->url; ?>'> Back </a> <a href='<?=$pages->get("/gallery/")->url?>'> Back </a> (ie. you were missing an echo or short echo statement there.) edit: fixed broken selectors to avoid confusion.. Edited July 25, 2013 by teppo 3 Link to comment Share on other sites More sharing options...
Godfrey Posted July 24, 2013 Author Share Posted July 24, 2013 @arjen and @teppo: Ohhh, didn't know about the necessary backslashes around "gallery". (I looked on the cheatsheet and the example for get() was $pages->get("selector") ) This worked!: <a href='<?php echo $pages->get("/gallery/")->url?>'> Back </a> Woops, both the missing "echo" and $albumimage were silly mistakes of my when typed this question (@arjen you were right), sorry about that! @teppo, for some reason this wasn't working for me and broke my code: <a href='<?php echo $pages->get("gallery")->url?>'> Thanks both! Link to comment Share on other sites More sharing options...
kongondo Posted July 25, 2013 Share Posted July 25, 2013 Like Arjen said, $pages->get("gallery") will not get you anything; you will get an unknown selector operator since PW doesn't know what gallery is Lots of "get" examples here: http://processwire.com/api/variables/pages/ http://processwire.com/api/variables/page/ 1 Link to comment Share on other sites More sharing options...
teppo Posted July 25, 2013 Share Posted July 25, 2013 @teppo, for some reason this wasn't working for me and broke my code: Sorry for that -- for some reason I simply copied your original (non-working) selectors and didn't fix them for my examples.. 2 Link to comment Share on other sites More sharing options...
Godfrey Posted July 27, 2013 Author Share Posted July 27, 2013 No problem I can't say much given the errors in my original post :B 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