Jump to content

placeholder text

Go to solution Solved by Martijn Geerts,

Recommended Posts

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 post
Share on other sites
  • Solution
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....';

  • Like 1
Link to post
Share on other sites

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 post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By RyanJ
      Based on the structure below, "employee", "department" and "year" are simply place holder "pages". Each have been assigned a blank template and contain only a title field which is required. They serve no other purpose.
      The issue I was seeing is that I could access these pages in the url directly. For example, root/location1/employee/ would simply display a blank page. This is undesirable for me as it made me fell empty and marking the page as hidden in the back-end did not resolve the issue. So I saw the option unpublished in the back-end and it works perfectly.
      I then found Ryan's post here which explains a lot but this example I think deserves its own topic. Would my handling of this be considered advisable or would something else be a better solution, like a 301? I noted that marking a page hidden excludes it from the find() method, but I simply grabbed the children by their templates.
      Location 1
        - Employee
           -- John Doe
           --Jane Doe
        - Department
          -- Confused Department
          --Even More Confused
          -- 2013
          -- 2014
    • By onjegolders
      Thought I'd point out a fantastic resource for placeholder images. Rather than the usual grey boxes or kittens...
      The usual /300x400 urls apply.
      Also if you want to avoid seeing the same images crop up again and again, you can use a tiny js file
      You won't go back!
    • By PawelGIX
      Can I specify default value for certain input field?
      For example:
      <h1>Title</h1><h2>subtitle</h2><p>article content</p>. in body InputField.
      Maybe custom module?
      Some hints?
  • Create New...