closer12 Posted January 25, 2015 Share Posted January 25, 2015 Hi, i am new on processwire. I have a field name is "price" .. and i want to show this field in the template if price is written, but if not i want to display text " plase ask " ... I filled placeholder text but it doesnt display. this is very simple but i dont know php , can you help me? Link to comment Share on other sites More sharing options...
Martijn Geerts Posted January 25, 2015 Share Posted January 25, 2015 It is just a HTML5 placeholder attribute. It just shows text in a field until the field is focused. See it as a helper for editors (who are smart enough to use a modern browser) For the PHP part, an if statement like this will work. if ($page->price) { echo $page->price; } else { echo 'Please ask....'; } 1 Link to comment Share on other sites More sharing options...
closer12 Posted January 25, 2015 Author Share Posted January 25, 2015 Thank you Martijn Geerts Link to comment Share on other sites More sharing options...
closer12 Posted January 25, 2015 Author Share Posted January 25, 2015 I tried with this ( pages field ) when its selected ok but when not selected it didnt work , do i make something wrong? if ($page->hotelisim) { foreach($page->hotelisim as $isim) echo "<tr>"; echo "<td>{$isim->title}</td>"; foreach($isim->children as $kucuk) echo "<td><li><a href='{$kucuk->url}' target='_blank'>{$kucuk->title}</a></li></td>"; echo "<td>{$isim->hotelclass}</td>"; echo "</tr>"; } else { echo 'Please ask'; } Link to comment Share on other sites More sharing options...
kongondo Posted January 26, 2015 Share Posted January 26, 2015 if $page->hotelisim is a Multiple page field, then use count() instead (because it returns an array).. if(count($page->hotelisim)) { //do your foreach stuff here } else { echo 'Please ask'; } 1 Link to comment Share on other sites More sharing options...
closer12 Posted January 26, 2015 Author Share Posted January 26, 2015 Thank you kongondo worked 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