PolyCMS Visual Portal and Publishing Engine for RISE CRM

PolyCMS Hooks and Filters Complete Reference for RISE CRM

Editing core plugin files inside RISE CRM guarantees painful merge conflicts whenever a security patch or minor release ships. PolyCMS exposes an event-driven action and filter architecture on top of CodeIgniter 4 so engineering teams can extend rendering, headers, and persistence cleanly.

Follow this reference to register deterministic callbacks, control execution priority, and isolate business logic inside your active theme or companion sub-plugin.

Before deploying custom callbacks to production, review PolyCMS Database Backup and Restore for RISE CRM for rapid rollback safety.

Hook CategoryTrigger PointReturn ContractCommon Use Case
Head & Asset ActionsTemplate <head> and footer renderVoid (echoes escaped HTML)Inject meta tags, schema, analytics
Content FiltersBefore rendering post or page HTMLModified string returnedWrap callouts, rewrite links, add TOC
Admin Menu ActionsRISE CRM sidebar initializationVoid (registers routes)Add sub-plugin settings screens
Save & Publish FiltersPre-persist payload validationFiltered array returnedEnforce slugs or auto-fill SEO defaults

1. Action Hooks vs. Data Filters in CodeIgniter 4

PolyCMS separates side-effect triggers from value transformation pipelines. Action hooks fire at lifecycle milestones like theme bootstrap and head rendering with no return value. Filter callbacks accept a payload and must always return the modified value. When injecting sidebar markup, pair slots with Widgets and Sidebars in PolyCMS for RISE CRM.

  • Register hooks inside your custom theme bootstrap or a dedicated companion sub-plugin file.
  • Always return the first parameter at the end of every filter callback to avoid blank output.
  • Namespace callback names or use static class methods to prevent global symbol collisions.
  • Escape dynamic variables with CodeIgniter esc() helpers before echoing in template actions.

2. Priority Ordering and Parameter Signatures

Every hook listener accepts a numeric priority defaulting to 10. Lower integers execute first, letting sanitizers normalize values before later callbacks append HTML wrappers or tracking attributes.

  • Use priority 5 or lower for early normalization, validation, and permission checks.
  • Keep standard extensions at priority 10 to preserve predictable third-party ordering.
  • Assign priority 50 or higher for final wrappers, schema JSON-LD, or closing scripts.
  • Declare exact accepted argument counts so optional context objects pass without warnings.

3. Testing Upgrade Safety Before Production Rollout

Keeping customizations behind hooks ensures core PolyCMS updates apply cleanly. Run a quick staging audit whenever RISE CRM or PolyCMS ships a minor release.

  • Inspect CI4 writable logs for deprecated hook notices after updating PolyCMS on staging.
  • Guard external helper calls with function_exists() or class_exists() inside sub-plugins.
  • Profile page timing via CI4 Debug Toolbar to spot slow database queries inside hooks.

Common Pitfalls & Quick Fixes

  • Blank Content After Filter: Callback omitted return $content;. Add an explicit return statement on every branch.
  • Hook Fires Twice: Registration sits in a repeated view partial. Move listeners into the single theme or plugin bootstrap.
  • Admin Save Hook Ignored: Hook name or load order mismatch occurred. Verify plugin load sequence and log listener execution.

Frequently Asked Questions

Where should I place custom PolyCMS hooks so updates never delete them?

Place all custom hook and filter registrations inside your dedicated child theme bootstrap or a standalone PolyCMS sub-plugin directory. Never modify files inside the core PolyCMS plugin folder, because installing any version update replaces core controllers, helpers, and views cleanly on disk.

What happens if a filter callback throws an unhandled exception?

An uncaught exception halts the CodeIgniter 4 request cycle immediately and returns an HTTP 500 error in production. Wrap external API calls or risky queries inside try-catch blocks, log failures to writable/logs, and return the unmodified input payload safely as a fallback.

Can PolyCMS hooks read authenticated RISE CRM client or staff session data?

Yes. Because PolyCMS runs natively inside the RISE CRM CodeIgniter 4 application container, hook callbacks can inspect active login session context and user role permissions directly. Always verify explicit authorization checks before rendering any restricted CRM records onto public-facing templates.

How do I debug execution order when multiple callbacks attach to one hook?

Inspect the registered priority integers on each attachment call, where lower numbers always execute earlier in the queue. On staging, temporarily log each callback identifier inside your listener or enable the CI4 Debug Toolbar to trace exact hook timing and invocation sequence.


Comments

Leave a Reply

Your email address will not be published.Required fields are marked *