Open fredericalpers opened 8 months ago
As a real estate agent utilizing the onOffice for WP-Websites plugin, I encounter inefficiencies when creating e.g. new property lists. Currently, if I have customized the template for displaying property lists and renamed it from the default name, subsequent property lists do not automatically select the custom template. Instead, the plugin defaults to the provided default template, leading to manual selection and potential errors.
@fredericalpers Your desired state means: When creating e.g. a new property list, property details, or new forms, and in the template selection of the "Layout & Design" box, "select renamed custom templates" will be the priority, right? e.g. I customized a template and renamed it "custom_template" from the "default" template in the "estate" folder of "template.dist". => Your desired state is that: When creating e.g. new property lists, "custom_template" will be prioritized selection of renamed custom templates
- Investigate the current mechanism for template selection in the onOffice for WP-Websites plugin
@fredericalpers Here are the results of my investigation of "current mechanism for template selection in the onOffice":
1.1.Prioritize: Template selection will be prioritized in folder order as follows: onoffice-theme in the WordPress "themes" folder => Plugin "onoffice-personalized" => "templates.dist" of wp onoffice plugin 1.2.Mechanism of operation(Mechanism of Saving template selection to Database) Step 1: Selected template(default.php) information will be saved in the config as a URL For example: onoffice-theme/templates/estate/default.php. Step 2: When Changing Template Name, Only the name of the template file is changed. URLs saved in the config are not updated accordingly. ex: When user has behavior to add a listview estate and select template "defautl.php". Selected template information(onoffice-theme/templates/estate/default.php) will be saved in the config of => Because when the user renames the template in the custom template folder(default.php => renameDefault.php) => The database cannot save the renamed template into the database
Your desired state is that: When creating e.g. new property lists, "custom_template" will be prioritized selection of renamed custom templates
that's correct :)
@fredericalpers Currently, we have found a solution based on using the "Creating Custom Page Templates for Global Use" mechanism. To create a global template, we need to write an opening PHP comment at the top of the file that states the template’s name. However, the considerations of utilizing WordPress's page templates file functionality to automatic selection of custom templates must ensure the following conditions: the directories must have permission to write data(put contents) to the file: 1.onoffice-theme/templates 2.onoffice-personalized/templates Because we use "file_put_contents" method to automatically write an opening PHP comment at the top of the file. This is a demo video: https://files.fm/u/8pu5n3fysk#/view/3uud7nhban You can review the code and test it in this branch: https://github.com/onOffice-Web-Org/oo-wp-plugin/tree/45378-automated-selection-of-renamed-custom-templates
@yeneastgate this seems to be working as we intended, thank you :)
@fredericalpers
the directories must have permission to write data(put contents) to the file: 1.onoffice-theme/templates 2.onoffice-personalized/templates
This is drawback of this solution. => I will continue to research to find a better solution can overcome this drawback and respond to you as soon as I find it.
@fredericalpers
According to the recommendation of WordPress Developer Resources (https://developer.wordpress.org/advanced-administration/server/file-permissions/#shared-hosting-with-suexec), the correct permissions is all directories should be 755 or 750.
For our solution, permissions are required for more "user:group" is "www-data" in addition to directory permissions is 755 with 2 directories : +"onoffice-theme" directory (wp-content/themes/{your theme}/onoffice-theme/templates) +"onoffice-personalized" directory (/wp-content/plugins/onoffice-personalized/templates)
As my knowledge: If the "/wp-content/themes" and "/wp-content/plugins" directories are owned by root or any other users other than "www-data", you may not be able to install plugins, add themes, or even upload files to your website from the dashboard backend WordPress.
An issue you may face is automatically installing plugins, and themes in the WordPress admin will require you to log in via FTP/SFTP if the files aren't owned by www-data.
=> So this solution "feasibility of utilizing WordPress's page templates file functionality" can be implemented with condition "/wp-content/themes" and "/wp-content /plugins" directories which have "user:group" is "www-data".
There is my analysis of the feasibility of this feature. So that you have a clear overview and hope to help you decide the plan for this issue.
Due to the priority and relevance of other issues and projects, this issue will be postponed to v5.3
Initiative
Enhance the usability of the onOffice for WP-Websites plugin
Epic
Implement automated custom template selection
User Story
As a real estate agent utilizing the onOffice for WP-Websites plugin, I encounter inefficiencies when creating e.g. new property lists. Currently, if I have customized the template for displaying property lists and renamed it from the default name, subsequent property lists do not automatically select the custom template. Instead, the plugin defaults to the provided default template, leading to manual selection and potential errors.
The current workflow for selecting templates for property lists lacks automation and introduces unncessary manual steps. This results in inconsistency and potential errors, especially when managing multiple property lists with custom templates. To address this issue and streamline the template selection process, I propose enhancing the plugin to automatically choose the correct custom template wheneber a new property list is created.
https://developer.wordpress.org/themes/template-files-section/page-template-files/
Tasks
By implementing automatic selection of custom templates for property lists, the onOffice for WP-Websites plugin can significantly enhance user experience and streamline workflow for web agencies and real estate agents managing property listings on a website.