Jump to content

How to copy template fields to a new template and keep it updated?


LAPS
 Share

Recommended Posts

In particular, I'm developing a new module that creates a copy of the user template and keeps that copy updated as regards the fields.

I think, the module needs these things:

  • a ___install() method that creates a new custom template copying the fields (with contexts/settings) of the user template.
  • a hook method (maybe stated in ready()) that checks if the user template has been updated and if so updates the custom template accordingly so to have the same fields in both user and custom templates.

How can I make?

Link to comment
Share on other sites

2 hours ago, LAPS said:

I'm developing a new module that creates a copy of the user template and keeps that copy updated as regards the fields.

Instead of doing this, try the following instead:

1. In /site/config.php set $config->advanced = true;

2. Create your user_copy template (whatever you want to call it)

3. On the "Basics" tab of Edit Template, select "user" for "Fieldgroup" and save.

4. Remove the line you added in step 1.

Now the user_copy template will always have the same fields as the user template.

  • Like 1
Link to comment
Share on other sites

When I manage to remove the 'pass', 'email', 'roles', and 'language' fields of the user_copy template and save then I get this error message:

Quote

Field 'pass'/'email'/'roles'/'language' may not be removed from fieldgroup '' because it is permanent (Field::flagPermanent). Save of fieldgroup changes aborted.

The only field I have been able to remove was the 'admin_theme'.

Link to comment
Share on other sites

To remove the 'pass', 'email', 'roles', and 'language' fields from the user_copy template, I had to temporarily disable their "system" and "permanent" statuses for each field by unchecking the related options in the Advanced tab of Edit Field. After this, I was able to complete the step 3 successfully.

  • 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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...