Jump to content

[RESOLVED] Echo a field from another page


Recommended Posts

I'm trying to echo a field from another page, in my footer. I have a Website Settings page (id 1006) with several fields for general site settings, like store hours (field is named store_hours). In the footer, I have this:

<?php $settingsPage = $pages->get(1006); 
	echo $settingsPage->store_hours;

Shouldn't that output the contents of that field? Right now it's printing a "0" (zero) on the page.

Elsewhere in the same footer template file, I have this code and it works fine:

<?php $homepage = $pages->get(1); 
	echo $homepage->body;

Does it have anything to do with the fact that the field is organized into one of these tabs, at the top of the page editor?

(disclaimer: I'm new to PW, and have inherited this site from another developer; that's why I don't know how or why some of this stuff is set up the way it is).


Screen Shot 2017-11-27 at 12.51.31 PM.png

Link to comment
Share on other sites

18 minutes ago, maxf5 said:

Is that page unpublished maybe?

That won't matter because he is using $pages->get() rather than $pages->find()

I think you do need to confirm 1006 and if that is correct, try $settingsPage->id to make sure that works - that way you can narrow down if it's a problem with the page or the store_hours field.

  • Like 1
Link to comment
Share on other sites

Just now, adrian said:

That won't matter because he is using $pages->get() rather than $pages->find()

Actually, I do wonder about that - what version of PW is this? Maybe the behavior of get has changed since the early days, but I don't think so.

Link to comment
Share on other sites

It's PW v 2.3. I checked the publish settings, and it was set to "Hidden: Excluded from lists and searches". I tried unchecking that box but I still get a zero. The id for the page is right in the URL when you're editing the page, right?

This is the URL when I edit that page:


Yeah, it's really weird, because like I said, I'm already using the exact same technique to echo a field from the homepage, but it's not working for this other page. :S

Link to comment
Share on other sites

Thanks @adrian! That helped me track the problem down. Turns out there are two fields on this site for store hours, for some reason, and the one I needed was store_hours_content, not store_hours. :S

I wish there was a way to see the field name when you're editing the page itself, rather than having to dig through the Templates and Fields areas of the backend.

Anyway, chalk this one up to user error. :/

Link to comment
Share on other sites

9 minutes ago, mike62 said:

I wish there was a way to see the field name when you're editing the page itself

Two options:

1) Admin On Steroids gives a tooltip to show field names and link to edit them:



2) Tracy shows a list of fields (and their values and settings for the page being edited. This is available from the Request Info Panel


  • Like 2
Link to comment
Share on other sites

Cool thanks! I also just discovered that I could have just been using: 

echo $settings->store_hours_content;

without even needing to use


Is there some way that the Website Settings page (1006) has been defined as some kind of global $settings variable?

Link to comment
Share on other sites

4 minutes ago, mike62 said:

Is there some way that the Website Settings page (1006) has been defined as some kind of global $settings variable?


Obviously you can search the code files under site, but also if you turn on the Template Resources panel in Tracy Debugger it will show you where it was defined.

Just now, kongondo said:

Really??...on PW 2.3? :P

Yeah, sorry - good point!

@mike62 - you really should upgrade this site!

Link to comment
Share on other sites

1 hour ago, mike62 said:

I wish there was a way to see the field name when you're editing the page itself

Another option: set $config->debug = true in /site/config.php (which is a good idea in general while developing a site) and then hover the inputfield collapse/expand icon in Page Edit.


  • Like 1
Link to comment
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 sambadave
      Hi there
      Short version of question
      Let's say I have a page in the admin that contains a field... Is it possible to output the content from that field on another page in the admin? Almost like a reference.
      Longer version of question (with example)
      A house builder with multiple (60+) developments. They want to be able to create notices/messages that can be added to one or many developments. Handy for things like regional covid lockdowns or temporary office closures due to bad weather.
      My approach for the admin editing options:
      Add each message to each development
      Pros: You edit the message on the development page in context
      Cons: Very time consuming and repetitive if the same message needs to be applied to 60+ developments
        Control all the messages from one admin page and say which development each message should be applied to
      Pros: Easier to add/remove messages to more than one development at a time. Control all messages from one place.
      Cons: Content is not added on development page, which is where typical admin users may expect to find it I went for option 2 due to flexibility, and created a page within the admin for global development notices. This contains a repeater with:
      Field for message to display Checkbox list of all developments. The user can select which ones to apply each message to It's working really well but the only thing is that if the user goes to a specific development in the admin, the relevant messages aren't displayed in context (as they aren't edited on that page and instead on the global development notices page)... which may cause confusion when a new staff member / content admin tries to edit the text but there is no field when they go to the development admin page where they expect to see it...
      I don't require the message(s) to also be editable on the development page, but I wondered if there was a nice way to show it/them somehow. I feel like I am missing something really simple as I'm sure ProcessWire will have a nice way of achieving this, or maybe there are field settings that allow this kind of thing to happen?
      Any ideas on approaches or similar experiences would be much appreciated, even if it is just a much simpler example with the content from one field being shown on another admin page to get the ball rolling.
      Thanks in advance for any advice :)
    • By franciccio-ITALIANO
      Hi everyone.
      I've created 12 templates that are the same but each with an extra bit of html code. 
      The piece of code is as follows:
      <div> <div class="box-pf"> <i class="fa fa-map-pin fa-2x fa-red faa-pulse animated"></i> <a href=""> <span class="uk-text-middle"><i>Sonchus oleraceus</i> 'Grespino degli Orti'</span></b> </a> </div> </div> On the third line we read "fa-red."
      I created 12 similar templates.
      The first template has only one box with fa-red, the last template has 12 boxes with icons of 12 different colors.
      So. is there any way to have only 1 template and add, if I want and when I want, a small or big, same or different piece of html code?
    • By daniel_puehringer
      Hi community, thanks for the great work you do 🙂

      I´m looking for a global field which can be used in the footer and has only one instance for all pages. So I´m kind of looking for "One field to rule them all".
      Reason for my question: The website I´m currently building has one footer for all pages. The content of the footer should be dynamic - therefore I made a global field which is automatically inserted into each page.
      Problem: if I want to change something in the footer, I have to do it for all fields, because each field has it´s own instance.

      Question: is it possible to have one global field in which changes the content for the footer of all pages?

      In most CMS Systems a simple solution to this is often impossible, I hope that processwire is different 🙂

      All the best,
    • By Brian Peat
      Hello! I've got a single client on Processwire and it's completely foreign to me. I've been able to find most things, but they've asked for a custom designed page with a full width header image/section, and then a body block and a right side bar below the header. They're using a landing page template, so I duplicated that, figured out how to add it in the admin, and assigned it to the page. Nothing. It doesn't change a thing.
      I feel like I'm missing something obvious. I've made sure all the fields are the same, I tried to set up the parent/child stuff though this page doesn't have a parent that I can tell (though it's under Landing Pages). If I can get the template to actually kick in, I think I can use a bit of code to check for the hero section and load it at the top. I also made a copy of the widget template and set that to load instead of the original. But again, since my main page template isn't kicking in, neither is the new widget template.
      I'd just love some tips on what to check or change to get a landing page to actually render what's in the assigned page template.
      Hopefully I've used the correct terminology here to make sense.
    • By rookie
      hi there,
      Is there a module or other solution to select a template with a preview image? Sometimes it is not that easy to describe a template.
      e.g. Template with 3 columns (image, title, content, button) or template for a slider with max. 4 pictures.
      Even if it is nice to have a description field for a template, a picture says more than thousand words could describe.
      And no, I don't think I could develop something like that. I don't even know where to start.🙄
  • Create New...