# Setting up a controller for ACF fields

**URL:** https://discourse.roots.io/t/setting-up-a-controller-for-acf-fields/11759
**Category:** sage
**Tags:** sage9
**Created:** 2018-02-28T17:43:07Z
**Posts:** 34
**Showing post:** 26 of 34

## Post 26 by @alwaysblank — 2018-05-22T21:31:21Z

You seem to be making the assumption that Controllers are linked to Blades—i.e. that content from `Controller.php` will be automatically piped to `controller.blade.php`. This is not the case. **Controllers are linked to the [WordPress Template Hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/)**—i.e. content from the Controller in `Page.php` will appear at locations where WordPress would load the `Single Page` template. There is no way (that I’m aware of) to target individual Blades from Controllers.

The way both Controller and Sage’s own routing do this is by hooking into the values that pass through the `body_class` filter, and loading the appropriate content. You can determine what controller should be used for your page by looking at the value of the `class` attribute on your page’s `<body>`. For instance, take a look at this page:  
 ![image](https://discourse.roots.io/uploads/default/original/2X/a/a267217d76f037cbbdb2240b74492a9b7a7b863f.png)  
If I wanted to target this with a controller, I could use a Controller called `Single` or `LocationTemplateDefault`, because of these classes:  
 ![image](https://discourse.roots.io/uploads/default/original/2X/b/b1e63bb1399a1a3962141ab4702fb6877961eb56.png)  
Controller names need to conform to PSR-4 naming standards, which is why it’s `LocationTemplateDefault`, not `location-template-default`.

If your goal is to encapsulate functionality you intend to use on several controllers, you might try using `traits` as described in the [Controller documentation](https://github.com/soberwp/controller/). They won’t allow you to target specific Blades, but they will allow you to re-use content across Controllers.

---

_[View the full topic](https://discourse.roots.io/t/setting-up-a-controller-for-acf-fields/11759)._
