Jump to content
shogun

How to do a Global Field?

Recommended Posts

How do you create a single field that is global across all pages and templates so that when its content is updated, it's updated every it exists on the website?

Share this post


Link to post
Share on other sites

Although you can't create a global field, you can access fields from any page on any template, so you could create a settings 'page' that isn't visible on the site, but holds any fields that you want to use globally, and then access them in every template eg:

$global = $pages->get('name=settings');

echo $global->myfield;

Remember that in Processwire, everything is a 'page', but it doesn't have to be an actual visible page on your site.

  • Like 4

Share this post


Link to post
Share on other sites

Can we use the same system to create a field that is on a template, that gets updated on all pages that use the template with the field? or is this the only way to do that...

Share this post


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.

×
×
  • Create New...