⌘K

Rendering Functions

All rendering functions are available in theme templates. Functions prefixed render_ return a string — always echo them. Functions that start with get_ return a value for further processing.


Content rendering

render_content_html(string $html, array $item = null): string

Full rich content pipeline: shortcode parsing (galleries, TOC, callouts, quotes, buttons, [recent_articles], [recent_projects], [contact_form]…). When $item['content_format'] === 'markdown', Markdown is converted to HTML first, then the shortcode pipeline runs.

🚫

Never display $item['content'] directly. Always pass through this function.

echo render_content_html($item['content'] ?? '', $item);

The second argument $item is required whenever the content contains inline galleries ([gallery id="N"]). Omitting it causes galleries to render empty.


Page structure

render_site_logo(array $settings, string $class = '', string $alt = ''): string

Returns an <img> tag for the site logo configured in settings. Returns empty string if no logo is set.

render_site_favicon(array $settings): string

Returns the <link rel="icon"> tag for the configured favicon. Returns empty string if none is set. Detects MIME type from file extension (ico, svg, png, gif, webp).

render_site_title(array $settings, string $pageTitle): string

Returns the site title string for use in the header, respecting the show_site_title_in_header setting.

render_meta_tags(array $settings, string $metaTitle, string $metaDescription, array $pageData = null): string

Generates all SEO tags: meta description, Open Graph, canonical URL, and JSON-LD schema.org markup.

render_header_scripts(array $headerScripts): string

Injects all <script> and <link> tags into <head>. Call once only in header.php.

Injection order:

  1. <base> tag
  2. css/synaptikCSS.php (combined system CSS: gallery layouts, lightbox, search, shortcodes)
  3. theme/{active}/css/style.css (with ?v=mtime cache busting)
  4. js/main.js (with ?v=mtime cache busting)
  5. RSS feed <link>
  6. $headerScripts (conditional gallery scripts, window.appSettings, etc.)
  7. theme/{active}/js/script.js (deferred, if the file exists)
  8. window.CMS_LANG i18n bridge

render_site_logo(array $settings, string $class = '', string $alt = ''): string

Returns an <img> tag for the site logo configured in Settings. Returns empty string if no logo is set.

echo render_site_logo($settings, 'site-logo');

render_site_favicon(array $settings): string

Returns the <link rel="icon"> tag for the configured favicon. Detects MIME type from file extension (ico, svg, png, gif, webp). Returns empty string if none is set.

render_site_title(array $settings, string $pageTitle): string

Returns the site title string for use in the header, respecting the show_site_title_in_header setting.

render_adminbar(): void

Renders the 36px admin toolbar if an admin session is active. No-op for regular visitors. Call as the first child of <body> in header.php to avoid stacking context conflicts with backdrop-filter navigation. See Theming Guide — Admin bar offset.


Content item parts

render_content_title(array $item): string

Returns the <h1> title block. Returns empty string if $item['show_title'] is false.

render_featured_image(array $item): string

Returns the <div class="featured-image"> block. Returns empty string if no image is set or show_featured_image is false.

render_content_date(array $item): string

Returns the publication date block if show_date is enabled, formatted per the date_format setting.

render_content_category(array $item): string

Returns the category badge link. Returns empty string if no category is set.

render_content_tags(array $item): string

Returns the tag links block. Returns empty string if no tags are set.

render_content_gallery(array $item): string

Returns the legacy gallery block from $item['gallery']. For inline galleries defined in $item['galleries'], use [gallery id="N"] shortcodes inside content instead.

render_footer_content(): string

Returns the footer text (supports {year} placeholder) and optional social links block.


Article & project cards

render_article_card(array $article): string

Delegates to partials/article-card.php if it exists in the active theme; uses the built-in default otherwise. See Partials.

render_project_card(array $project): string

Delegates to partials/project-card.php if it exists; uses the built-in default otherwise.

get_article_summary(array $article, int $length = 150): string

Returns an HTML-safe summary. Uses $article['summary'] if defined; otherwise auto-generates a clean excerpt via _clean_excerpt(). Loads the full item on demand if content is absent (index-mode context). Ready for direct echo.

echo get_article_summary($article);
echo get_article_summary($article, 200);

Homepage sections

render_home_articles(array $data, array $settings): string

Generates the article grid for the homepage with pagination. Respects show_articles_on_homepage, articles_per_page, and per-article show_on_homepage.

render_home_projects(array $data, array $settings): string

Generates the project grid for the homepage. Respects show_projects_on_homepage and projects_per_page.


render_related_items(array $item, int $limit = 5): string

Renders a related content section. Returns empty string if $item['show_related_items'] is not true.

Manual mode — if $item['related_items'] is a non-empty array of {type, slug} references, those exact items are resolved and displayed. The $limit parameter is ignored in manual mode.

Auto mode — if related_items is empty, candidates are scored by shared tags (+1 each) and matching category (+2). Top results up to $limit are returned. Only index data is read.

echo render_related_items($item);
echo render_related_items($item, 3);

Custom fields

render_item_custom_fields(array $item, string $type): string

Renders all non-empty custom fields as a <dl>, respecting schema order and labels from Settings. URL fields are rendered as links, checkbox fields as checkmarks, text/number fields with nl2br. Returns empty string if no schema is defined or no values are set.

echo render_item_custom_fields($item, 'article');

get_custom_field(array $item, string $key, mixed $default = ''): mixed

Returns the value of a single custom field. Returns $default if absent or empty.

$price    = get_custom_field($item, 'price', 'N/A');
$isOnline = get_custom_field($item, 'is_online'); // '1' or ''

render_custom_fields(array $item): string

Renders all non-empty fields as a plain <dl> without schema ordering or label resolution. Useful for debugging; prefer render_item_custom_fields() in production.


render_search_ui(): string

Generates the full HTML for the search overlay (#search-overlay). Always generated regardless of show_search_icon — ensures Ctrl+K works even when the icon is hidden. Call before </body> in footer.php.

🚫

Do not call rendersearchui() in footer.php. main.js builds the search overlay itself; calling this in PHP produces a conflicting duplicate DOM structure. The function is called automatically by the CMS after footer.php renders.

render_search_icon(): string

Generates the <li> search icon for the navigation bar. Returns empty string if show_search_icon is false.

get_search_icon_html(): string

Legacy alias for render_search_icon().

get_search_overlay_html(): string

Legacy alias for render_search_ui().


Galleries

renderGallery(array $galleryItems, string $layout = 'grid'): string

Dispatches to the appropriate gallery renderer. Supported layouts: 'grid', 'masonry', 'justified', 'carousel'.

renderGridGallery(array $galleryItems, string $galleryId): string

renderMasonryGallery(array $galleryItems, string $galleryId): string

renderJustifiedGallery(array $galleryItems, string $galleryId): string

renderCarouselGallery(array $galleryItems, string $galleryId): string

Direct renderers for each layout type. Use renderGallery() unless you need to force a specific layout unconditionally.

getGalleryScripts(string $galleryLayout): string

Returns the inline JS/CSS required for a given gallery layout. Called automatically when a gallery shortcode is parsed.


Navigation & menus

render_menu(array $settings, array $data): string

Generates the main navigation. Uses the custom menu builder output if use_custom_menu is enabled; otherwise calls renderDefaultMenu().

renderHierarchicalMenu(array $settings, array $data): string

Hierarchical menu with dropdown sub-menu support.

renderDefaultMenu(array $data): string

Flat auto-menu from all content marked show_in_menu, sorted by menu_order. Always reloads fresh indices via sl_load_index() — safe to call from uncertain contexts.


Contact form

render_contact_form_html(): string

Full contact form with CSRF protection, honeypot, rate limiting, and optional hCaptcha. Injects contact.css once per page via a static flag. Callable directly in templates or via [contact_form].


Breadcrumbs

getBreadcrumbs(string $type, string $slug = '', string $title = '', string $category = ''): string

Generates HTML breadcrumbs for any page type. Category links resolve the full hierarchical path.


Pagination

get_pagination(int $total_items, int $items_per_page, int $current_page, string $type): string

Generates HTML pagination links. Returns empty string if there is only one page.

echo get_pagination(count($articles), $settings['articles_per_page'], $currentPage, 'article');