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 349183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:26:04+00:00 2026-05-12T11:26:04+00:00

I have a class that gathers templates and displays the final output after connecting

  • 0

I have a class that gathers templates and displays the final output after connecting all the templates.

class Template{

$private $output = '';

public function Load_Template($template, $data = null){
    ob_start();
    include($template);
    $this->output .= ob_get_clean();
}

public function Display($add_footer = true){
    echo $this->output;
}

}

Now, Currently my templates look something like this.

<h1><?php echo $data['name']; ?></h1>

or the more complex ones that involve loops look more like

<ul>
  <li>
  <?php foreach($data as $user){ ?>
   <h1><?php echo $user['name']; ?></h1>
  <?php } ?>
  </li>
</ul>

Actually theres way more data than that in them, but im sure you guys get the point.
Now, I have heard people say thats it better to have templates like this

<h1>{name}</h1>

or

<ul>
  <li>
   <h1>{name}</h1>
  </li>
</ul>

and then use a str_replace function… Now, if im using a foreach loop, how would I accomplish something like this… should i alter my class, and if so can i get some ideas as to how… And do you guys suggest using templates with

  • 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-12T11:26:05+00:00Added an answer on May 12, 2026 at 11:26 am

    Smarty is too redundant! Your class with the function of cutting a page is enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that creates a view to gather data via a function
I have a method in a client class that gathers data from a server,
I have class that represents users. Users are divided into two groups with different
I have class A such that: class A { static int i; A(); f1();
I have a class that implements the IDisposable interface. I am using a webclient
I have a class that is marked with DataContract attributes and I would like
I have a class that requires a specific method to be called before being
I have a class that maps incoming messages to matching readers based on the
I have a class that I am using below. And I am using this
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but

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.