Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally determine context from config.context.php #16045

Merged
merged 2 commits into from
Feb 16, 2022

Conversation

opengeek
Copy link
Member

@opengeek opengeek commented Feb 8, 2022

What does it do?

Allows the /index.php file to look for an optional /config.context.php file in the same directory which returns the context key to use when initializing the modX class.

Why is it needed?

This will allow a site to initialize a default context other than web based on simple logic determined in the optional /config.context.php file.

How to test

Add a /config.context.php file in the base_path where the MODX /index.php file is which returns a string representing the context key to use when calling modX::initialize(). Ensure that this initializes the context you expect.

Related issue(s)/PR(s)

Related to #14962
Alternative to #15944

Allow the index.php file to look for an optional config.context.php file in the same directory which returns the context key to use when initializing the modX class.
@opengeek opengeek added the needs-docs The issue requires adding or updating documentation after the pull request merged. label Feb 8, 2022
@opengeek opengeek added this to the v3.0.0-pl milestone Feb 8, 2022
@opengeek opengeek requested a review from Mark-H as a code owner February 8, 2022 15:58
@cla-bot cla-bot bot added the cla-signed CLA confirmed for contributors to this PR. label Feb 8, 2022
Copy link
Contributor

@JoshuaLuckers JoshuaLuckers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended however if the context that's defined doesn't exist it will throw a Fatal error and exception. Maybe we should consider using the web context by default in that case? Or show the styled error page instead.

@Ibochkarev Ibochkarev added the pr/ready-for-merging Pull request reviewed and tested and ready for merging. label Feb 11, 2022
@opengeek
Copy link
Member Author

Works as intended however if the context that's defined doesn't exist it will throw a Fatal error and exception. Maybe we should consider using the web context by default in that case? Or show the styled error page instead.

This sounds like something that would need to be addressed inside initialize rather than in the index.php. Let's address that separately as it is the same issue regardless of how the wrong context is sent to the method.

@opengeek opengeek merged commit 704c29a into modxcms:3.x Feb 16, 2022
@opengeek opengeek deleted the config.context.php branch February 16, 2022 17:17
@modxcommunity
Copy link
Collaborator

This pull request has been mentioned on MODX Community. There might be relevant details there:

https://community.modx.com/t/context-routing-in-modx-3/8008/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed CLA confirmed for contributors to this PR. needs-docs The issue requires adding or updating documentation after the pull request merged. pr/ready-for-merging Pull request reviewed and tested and ready for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants