Jump to content

Regarding "$config->usersPageIDs" of new user templates in 2.5.14, the right hook?


blynx
 Share

Recommended Posts

Hi!

I am building a site where there is another user-template as introduced in 2.5.14.

(http://processwire.com/blog/posts/processwire-core-updates-2.5.14/#multiple-templates-or-parents-for-users)

For now, you have to add the parents of the users with the new user-template manually like so:

$config->usersPageIDs = array(29, 1026, 1027);

But I have dynamically growing pages which hold the new users, like so:

Home
  Members
    Group
      User
      User
    Group
      User
      User
      ...
    ...

Ryan mentioned they're working on automating that process, but I wonder how I could accomplish this now.

Naively I tried to fetch the parents like so, directly in config.php: (I'm quite novice :-[ )

$those_pages = $pages->find("template=that_template");

But that failed - nothing got rendered.

Then, I thought I could do that in the site template files. But that would be too late, I guess? Also this approach would be useless for the backend... and I guess I don't need this configuration for the fronted anyway!?

Now I wonder where would be the right hook to some function in the right time to accomplish this?

Or any other solution?

Hope you get what I mean ...  :ph34r:

Link to comment
Share on other sites

Just for the files:

Meanwhile I just grabbed the missing IDs per plain mySQL-queries:

$config->usersPageIDs = array(29);

$new_users = array();
$xyz_db = new PDO('mysql:host=localhost;dbname=bzzzzt;charset=utf8', 'root', 'root');
$xyz_stmt = $xyz_db->query("SELECT templates_id, id FROM pages WHERE templates_id = 46");
$xyz_results = $xyz_stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($xyz_results as $row) {
	$this_id = $row["id"];
	$new_users[] = $this_id;
}
$xyz_db = null;
$config->usersPageIDs = array_merge($new_users, $config->usersPageIDs);

(I just figured that this could be simplified ... ... later ...)

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
 Share

×
×
  • Create New...