Back to Main Site

PolyCMS Template Tags and Helper Functions for RISE CRM

Last updated on Nov 22, 2026 11:51 AM 11:51 AM 2,251.76 ms

PolyCMS for RISE CRM ships with a rich library of template tags and collision-proof RISE helper functions located in plugins/polycms/Helpers/. Theme and plugin developers can use these functions directly to generate dynamic permalinks, fetch CMS options, enforce RISE role permissions, purify HTML, render menus and widget areas, and output SEO tags without writing raw SQL or risking symbol conflicts with other RISE plugins.

RISE-Native Collision-Proof Helpers

Defined in plugins/polycms/Helpers/polycms_rise_compat_helper.php, these polycms_* adapters safely bridge PolyCMS with RISE CRM's CodeIgniter 4 runtime while avoiding naming collisions alongside other installed plugins.

Instance, Routing, and Storage Helpers

Function Signature Description
polycms_ci() polycms_ci() Returns the shared compatibility instance (db, load, input, uri, session, lang, staff_model)
polycms_admin_url() polycms_admin_url($uri = '') Builds a RISE CRM admin route URL (for example, polycms_admin_url('polycms/posts'))
polycms_site_url() polycms_site_url($uri = '') Builds a public site URL using RISE get_uri()
polycms_upload_base_url() polycms_upload_base_url($sub = '') Returns the public URL inside files/polycms/
polycms_upload_base_path() polycms_upload_base_path($sub = '') Returns the absolute filesystem path inside files/polycms/
polycms_writable_path() polycms_writable_path($sub = '') Returns the private writable path inside writable/polycms/ (cache, rate_limit, backups, htmlpurifier)
polycms_module_dir_path() polycms_module_dir_path('polycms', $concat = '') Resolves an absolute filesystem path inside plugins/polycms/
polycms_module_dir_url() polycms_module_dir_url('polycms', $concat = '') Resolves a public URL inside plugins/polycms/
polycms_redirect() polycms_redirect($uri = '', $method = 'auto', $code = 302) Safely redirects via HTTP header or JS fallback
$admin_posts_url = polycms_admin_url('polycms/posts');
$public_home_url = polycms_site_url('home');
$media_url       = polycms_upload_base_url('2026/05/hero-banner.webp');
$cache_dir       = polycms_writable_path('cache');

Options, Auth, RBAC, and Sanitization Helpers

Function Signature Description
polycms_get_option() polycms_get_option(string $name, $default = '') Reads from {prefix}blog_settings (cached per request) with fallback to RISE settings (app_title, date_format, time_format, timezone, language)
polycms_update_option() polycms_update_option(string $name, $value): bool Inserts or updates a setting in {prefix}blog_settings and refreshes the in-memory cache
polycms_add_option() polycms_add_option(string $name, $value = ''): bool Adds an option only if the key does not already exist
polycms_staff_can() polycms_staff_can(string $capability, string $feature = 'polycms', $staff_id = null): bool Checks RISE RBAC capabilities (view, create, edit, delete, settings); returns true for RISE Admins and full-settings roles
polycms_is_admin() polycms_is_admin($staff_id = 0): bool Returns true if the current or given RISE staff member is an administrator
polycms_is_staff_logged_in() polycms_is_staff_logged_in(): bool Returns true when a RISE staff session is active
polycms_is_client_logged_in() polycms_is_client_logged_in(): bool Returns true when a RISE client contact session is active
polycms_html_purify() polycms_html_purify($html): string Sanitizes HTML via plugin-local vendor/ezyang/htmlpurifier using writable/polycms/htmlpurifier/ cache
polycms_set_alert() polycms_set_alert(string $type, string $message): void Flashes a Bootstrap 5 admin notification (success, danger, warning, info)
polycms_log_activity() polycms_log_activity(string $description): void Logs a [PolyCMS] entry via CodeIgniter 4 log_message()
polycms_csrf_field() polycms_csrf_field(): string Outputs a hidden HTML input containing the active RISE CSRF token
polycms_l() polycms_l(string $key, $args = ''): string Translates a key across PolyCMS's 16 language packs (plugins/polycms/Language/) with fallback to RISE app_lang()
// Read and update CMS options safely
$per_page = (int) polycms_get_option('polycms_posts_per_page', 10);
polycms_update_option('polycms_custom_banner_enabled', '1');

// Enforce RISE CRM RBAC before rendering sensitive actions
if (polycms_staff_can('edit', 'polycms')) {
    echo '<a href="' . polycms_admin_url('polycms/posts/add') . '" class="btn btn-primary">New Post</a>';
}

// Sanitize untrusted HTML before saving
$clean_html = polycms_html_purify($raw_html);

URL and Asset Functions

These helpers live in plugins/polycms/Helpers/polycms_core_helper.php and automatically honor your configured blog prefix and permalink structure in PolyCMS > Permalinks.

polycms_blog_url($path = '') and polycms_get_blog_url()

Returns the base blog frontend URL with an optional appended path, or the normalized blog homepage URL with trailing slash rules applied.

$blog_home  = polycms_get_blog_url();
// Example: https://yourdomain.com/blog/

$search_url = polycms_blog_url('search');
// Example: https://yourdomain.com/blog/search

polycms_get_post_permalink($post) and polycms_get_page_permalink($page)

Generates the full canonical frontend URL for a post (matching %postname%, %year%/%monthnum%/%postname%, or custom permalink tags) or a root-level static page.

$post_url = polycms_get_post_permalink($post);
// Example: https://yourdomain.com/blog/getting-started-with-rise-crm/

$page_url = polycms_get_page_permalink($page);
// Example: https://yourdomain.com/about-us/

polycms_get_category_url($category) and polycms_get_tag_url($tag)

Generates archive URLs honoring custom category_base and tag_base permalink settings.

$cat_url = polycms_get_category_url($category);
// Example: https://yourdomain.com/blog/category/product-updates/

$tag_url = polycms_get_tag_url($tag);
// Example: https://yourdomain.com/blog/tag/automation/

polycms_asset_url($path, $module = 'polycms') and polycms_asset_path($path, $module = 'polycms')

Automatically resolves unminified development paths under assets/ to compiled Webpack bundles under dist/assets/ (.min.js / .min.css), falling back cleanly to the original file if a minified build is not present.

$script_url = polycms_asset_url('plugins/mtbuilder/assets/js/builder.js');
// Resolves to: https://yourdomain.com/plugins/polycms/plugins/mtbuilder/dist/assets/js/builder.min.js

Content Retrieval and Formatting Functions

Querying Models via polycms_ci()

Use polycms_ci() to load core PolyCMS models in themes, widgets, shortcodes, or custom plugins:

$CI = &polycms_ci();
$CI->load->model('polycms/Blog_post_model');
$CI->load->model('polycms/Blog_category_model');
$CI->load->model('polycms/Blog_tag_model');

// Fetch a single post by ID
$post = $CI->Blog_post_model->get_by_id(42);

// Fetch latest published posts in a category
$posts = $CI->Blog_post_model->get([
    'status'      => 'published',
    'category_id' => 5,
    'limit'       => 10,
    'sort_by'     => 'published_at',
    'sort_order'  => 'DESC',
]);

// Fetch hierarchical categories and tags
$category_tree = $CI->Blog_category_model->get_tree();
$all_tags      = $CI->Blog_tag_model->get();

polycms_get_post_excerpt($post, $length = 150)

Returns a clean, entity-decoded plain-text excerpt truncated on word boundaries, applying the polycms_post_excerpt filter and automatically protecting password-locked posts.

echo html_escape(polycms_get_post_excerpt($post, 160));

polycms_get_post_meta($post)

Returns an associative array of post metadata (author, author_id, published_at, created_at, updated_at, views_count, category_id, category_name, tags) passed through the polycms_post_meta filter.

$meta = polycms_get_post_meta($post);
echo html_escape($meta['author']);

Date, Slug, Breadcrumb, and Pagination Helpers

// Respects PolyCMS Localization settings (with fallback to RISE CRM settings)
$formatted_date     = polycms_format_date($post->published_at);
$formatted_datetime = polycms_format_datetime($post->published_at, true);

// Generate URL-friendly slugs (supports Latin and Vietnamese diacritics)
$slug = polycms_generate_slug('RISE CRM Release Notes 2026');

// Build breadcrumbs and pagination links
$crumbs = polycms_get_breadcrumb([['title' => $post->title, 'url' => '']]);
$pager  = polycms_generate_pagination($current_page, $total_pages, polycms_get_blog_url());

Rendering Functions

polycms_render_menu($location, $args = []) and polycms_get_menu($location)

Renders a nested navigation menu assigned to a menu location (such as 'main' or 'footer'), or returns the menu object with hierarchical items for custom markup.

polycms_render_menu('main', [
    'wrapper_class'     => 'nav-menu',
    'item_class'        => 'nav-link',
    'submenu_class'     => 'submenu',
    'has_submenu_class' => 'has-submenu',
    'echo'              => true,
]);

polycms_render_widget_area($area_id, $args = [])

Renders all active widgets assigned to a registered widget area (for example, 'sidebar' or 'footer').

polycms_render_widget_area('sidebar', [
    'before_widget' => '<div class="sidebar-widget mb-4">',
    'after_widget'  => '</div>',
    'before_title'  => '<h3 class="widget-title">',
    'after_title'   => '</h3>',
]);

polycms_do_shortcode($content)

Parses and executes all registered [shortcode] tags inside a content string.

$rendered_html = polycms_do_shortcode($post->content);

polycms_render_admin_bar()

Outputs the floating frontend admin bar (with quick Edit Post/Page, Edit with MTBuilder, and Clear Cache links) when a RISE CRM staff member is signed in.

if (function_exists('polycms_render_admin_bar')) {
    polycms_render_admin_bar();
}

SEO Functions

Defined in plugins/polycms/Helpers/polycms_core_helper.php, these helpers escape all attributes and apply their respective SEO filters before returning HTML markup:

echo polycms_get_seo_meta_tags([
    'title'       => $post->meta_title ?: $post->title,
    'description' => $post->meta_description ?: polycms_get_post_excerpt($post, 155),
    'keywords'    => $post->meta_keywords ?? '',
    'canonical'   => polycms_get_post_permalink($post),
    'robots'      => 'index, follow',
]);

echo polycms_get_open_graph_tags([
    'title'       => $post->title,
    'description' => polycms_get_post_excerpt($post, 155),
    'image'       => $featured_image_url,
    'url'         => polycms_get_post_permalink($post),
    'type'        => 'article',
]);

echo polycms_get_twitter_card_tags([
    'card'        => 'summary_large_image',
    'title'       => $post->title,
    'description' => polycms_get_post_excerpt($post, 155),
    'image'       => $featured_image_url,
]);

Theme and Conditional Tag Functions

Defined in plugins/polycms/Helpers/theme_api_helper.php and polycms_template_helper.php:

Function Description
polycms_head() Triggers polycms_enqueue_scripts, outputs enqueued styles, and fires polycms_wp_head
polycms_footer() Outputs enqueued footer scripts and fires polycms_wp_footer
polycms_body_class($extra = '') Returns context-aware CSS classes (is-homepage, is-single, is-page, is-category, theme-{slug})
polycms_theme_url($slug, $path = '') Returns the URL inside plugins/polycms/themes/{slug}/
polycms_theme_path($slug, $path = '') Returns the filesystem path inside plugins/polycms/themes/{slug}/
polycms_get_active_theme() Returns the active theme database record (id, name, slug, version)
polycms_get_active_theme_slug() Returns the active theme slug string
polycms_get_theme_option($key, $default = null) Reads a saved option configured at Appearance > Theme Options
polycms_locate_template($name, $context = []) Resolves a template file via child -> parent -> plugin fallback hierarchy
polycms_get_template_part($slug, $name = null, $args = []) Includes a reusable theme partial with data extraction
polycms_is_home(), polycms_is_single(), polycms_is_page(), polycms_is_category(), polycms_is_tag(), polycms_is_author(), polycms_is_search(), polycms_is_archive() Boolean conditional tags for context-aware rendering inside theme templates
$logo_url      = polycms_get_theme_option('site_logo', '');
$posts_per_row = (int) polycms_get_theme_option('posts_per_row', 2);

if (polycms_is_single()) {
    polycms_get_template_part('partials/share-buttons', null, ['post' => $post]);
}

Hook and Shortcode Functions

  • polycms_add_action($hook, $callback, $priority = 10, $args = 1) - Register an action callback.
  • polycms_add_filter($hook, $callback, $priority = 10, $args = 1) - Register a filter callback.
  • polycms_do_action($hook, ...$args) - Execute all callbacks attached to an action.
  • polycms_apply_filters($hook, $value, ...$args) - Transform a value through all registered filter callbacks.
  • polycms_register_shortcode($tag, $callback) - Register a custom shortcode handler.
  • polycms_unregister_shortcode($tag) - Remove a registered shortcode handler.

For the full list of hooks, see the Hooks and Filters Complete Reference.

Security and Utility Functions

Defined in plugins/polycms/Helpers/polycms_security_helper.php and polycms_core_helper.php:

Function Description
polycms_validate_file_path($path, $base_dir = null) Resolves realpath() and blocks null bytes, .. traversal, and escapes outside $base_dir
polycms_safe_include($file_path, $base_dir = null, $vars = []) Validates a .php file path before including it with extracted variables
polycms_sanitize_filename($filename) Strips path components and special characters for safe disk storage
polycms_safe_output($value, $context = 'html') Context-aware escaping for 'html', 'attr', 'url', or 'js'
polycms_purify_content($content) Runs polycms_html_purify() plus script/event-handler stripping for rich HTML content
polycms_check_permission($action, $resource = 'polycms', $log = false) Evaluates RISE RBAC permissions without spamming error logs during sidebar rendering
polycms_require_permission($action, $resource = 'polycms') Enforces RISE RBAC permission and denies access if unauthorized
polycms_clear_cache() Clears cached frontend HTML files in writable/polycms/cache/
polycms_table_sort_link($sort_key, $label, $sort_by, $sort_order) Generates sortable admin table column links used in PolyCMS list views

Need Developer Support?

If you need help using PolyCMS template tags or RISE CRM compatibility helpers in a custom theme or plugin, reach out on our CodeCanyon portfolio page. Free developer support is included for all PolyCMS customers.

Related Documentation