Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4054462
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:34:42+00:00 2026-05-20T14:34:42+00:00

This is probably a really easy question, so apologies for not being more challenging!

  • 0

This is probably a really easy question, so apologies for not being more challenging!

I am developing an in house CMS which uses a templating system.

To make this CMS as extendable as possible I want to use “modules”. Hence in the template files I want to put custom HTML tags which represent modules.

This will look like:

<p><Module name="newsTicker" property="value" anotherProperty="anotherValue" /></p>

I get my template file by using:

ob_start();
include "templatefile.tpl";
$buffer= ob_get_contents();
ob_end_clean();

Now I want to go through the contents of $buffer and for every occurance of <Module name="moduleName" /> I want to include "moduleName.class.php", create a new instance of that class, run the getOutput() function of that module and put the return value in where that <Module /> tag used to be.

I have no idea how to go about that… :/ Any ideas?

If you don’t understand think about a news ticker. I may write some code that looks through the news table in my database and makes a list of the 10 latest news stories, then it outputs it to a html <ul>. I want to abstract this so that it can be used on many pages. So in my template for the home page I might have the tag <Module name="newsTicker" />. Now when I visit the home page I need to look through the home page tpl file and I’ll find where it says <Module name="newsTicker" />, I’ll extract the name attribute and include a class based on that name (in this case it will be newsTicker.class.php). This will have a function called getOutput() so I will be able to something similar to: $output = $current_module->getOutput(); and then I need to go back to my tpl file and change the original <Module name="newsTicker" /> for the contents of $output.

Thanks for your help. 🙂

Tom

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T14:34:42+00:00Added an answer on May 20, 2026 at 2:34 pm
    • Use DOMDocument to find Module elements (I would use lowercase only personally).
    • Store name attribute.
    • include_once the class based on name attribute (skip if using autoloading).
    • Use $class = new $name.
    • Remove original Module DOM element and appendChild of $class->getOutput().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really easy question to answer, but for some reason I'm
This is probably a really easy question, but I can't find anything that works.
This is probably a really easy question, I want to access the last element
This is probably a really simple jQuery question, but I couldn't answer it after
This is probably a really stupid newbie-sounding question to you developer type people, but
This is probably a really stupid MSBuild question but if I have <ItemGroup> <Dll
This is probably a really simple question but... I would like to do a
I have what is probably a really dumb grep in R question. Apologies, because
This is probably really easy, but I'm lost on how to make sure it
This is probably a really obvious question, but it's driving me nuts. We have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.