ShahiAssist

Template Overrides

Template overrides allow you to customize the appearance and layout of ShahiAssist components without modifying the plugin core files. This ensures your changes survive plugin updates.

Understanding Plugin Templates

ShahiAssist uses template files located in includes/modules/*/views/ folders. These are PHP files that render the HTML output for various components like ticket forms, KB articles, and dashboards.

Template Hierarchy

    1. Plugin templates are loaded first.
    2. If a matching template exists in your theme’s shahi-assist/ folder, it overrides the plugin version.
    3. This follows WordPress’s standard template override pattern.
    4. How to Override Templates

      Step 1: Locate the Template

      Find the template you want to override in the plugin directory:

    5. Knowledge Base: includes/modules/knowledge-base/views/
    6. Ticketing: includes/modules/ticketing-system/views/
    7. Admin views: includes/admin/views/
    8. Step 2: Copy to Theme

    9. Create a folder shahi-assist in your theme root.
    10. Copy the desired template file(s) to this folder.
    11. Maintain the same subfolder structure if present.
    12. Step 3: Customize

      Edit the copied template file with your changes. You can:

    13. Modify HTML structure
    14. Add/remove CSS classes
    15. Include custom PHP logic
    16. Integrate with theme functions
    17. Step 4: Test

      Preview your changes and ensure functionality remains intact.

      Common Template Overrides

      Knowledge Base Templates

    18. single-article.php: Individual article display
    19. archive.php: Article listing page
    20. search-results.php: Search results layout
    21. Ticket Templates

    22. submit-ticket.php: Ticket submission form
    23. view-ticket.php: Ticket detail view
    24. ticket-list.php: Ticket listing
    25. Dashboard Templates

    26. dashboard.php: Main dashboard layout
    27. my-tickets.php: User ticket list
    28. Advanced Override Techniques

      Using Filters for Dynamic Overrides

      `php
      addfilter(‘shahiassisttemplatepath’, function($path, $template) {
      if ($template === ‘single-article.php’) {
      return gettemplatedirectory() . ‘/custom-shahi-assist/single-article.php’;
      }
      return $path;
      }, 10, 2);
      `

      Conditional Overrides

      Override templates based on conditions:
      `php
      addfilter(‘templateinclude’, function($template) {
      if (issingular(‘kbarticle’) && isuserlogged_in()) {
      $customtemplate = gettemplate_directory() . ‘/shahi-assist/single-article-logged-in.php’;
      if (fileexists($customtemplate)) {
      return $custom_template;
      }
      }
      return $template;
      });
      `

      Best Practices

      Maintain Compatibility

    29. Keep core functionality intact
    30. Use the same variable names and structures
    31. Test with different user roles
    32. Performance Considerations

    33. Avoid heavy computations in templates
    34. Use caching for dynamic content
    35. Minimize database queries
    36. Version Control

    37. Track your custom templates in version control
    38. Document changes for future updates
    39. Consider using child themes for overrides
    40. Security

    41. Sanitize all output
    42. Validate user input
    43. Follow WordPress coding standards
    44. Troubleshooting

      Template Not Loading

    45. Check file permissions (755 for folders, 644 for files)
    46. Verify folder structure matches plugin
    47. Clear any caching plugins
    48. Changes Not Appearing

    49. Hard refresh browser (Ctrl+F5)
    50. Check for syntax errors in PHP
    51. Ensure theme is active
    52. Conflicts with Theme

    53. Test with default WordPress theme
    54. Check for JavaScript conflicts
    55. Review CSS specificity
    56. Examples

      Custom KB Article Template

      `php


      `

      Modified Ticket Form

      `php




      `

      Resources

    57. WordPress Template Hierarchy
    58. Plugin Template Override Best Practices
    59. ShahiAssist Template Reference (see plugin code)

Share this article

Was this article helpful?

Help us improve our documentation

Still need help?

Our support team is ready to assist you with personalized guidance for your workspace.

Submit a support ticket