Jump to content

Selector for process?


Recommended Posts

Hi friends! And thanks for Processwire!

Maybe i'm missing something, but i have no idea how to select an (admin) page by the process it uses. It could look this:


This could be a great help while using a perfect ProcessSettingsFactory module (many thanks to @Macrura!). That module allows to create admin settings pages, each holding a certain set of configurable data fields. Getting that fields is a piece of cake:

$settings = $settingsFactory->getSettings('general'); //'general' is the name of admin page holding the settings
$phone = $settings->phone;

Works great when we need quite a limited number of settings. But when the things are getting bigger, it becomes quite reasonable to create a number of settings pages and to organize all the settings into a unified structure. Here's an example how it could be:

//getting all settings pages
$settingsPages = $pages->find("template=admin,process=ProcessSettingsFactory");

//creating the settings object
$settings = (Object)[];

//putting all data from settings pages into $settings object
foreach( $settingsPages as $settingsPage ){
	$settingName = $settingsPage->name; //e.g. 'general'
	$settings->$settingName = $settingsFactory->getSettings($settingName);

//now we can use the $settings object

echo "<a href=mailto:{$settings->general->email}>Mail us!</a>";

This approach definitely requires a process-specific selector. Guess that it could also be implemented at module level but having a specific selector for process could be useful in a large number of tasks.

Will appreciate any idea )

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.
  • Create New...