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

  • SEARCH
  • Home
  • 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 356699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:08:10+00:00 2026-05-12T12:08:10+00:00

I am going over/studying the facebook code that was leaked in 2007, I notice

  • 0

I am going over/studying the facebook code that was leaked in 2007,
I notice 1 function they call several times on on all the pages is this tpl_set(param1,param2) function

I am going to assume this is something to do with templates, The function has 2 parameters/variables passed into it, it looks like the first 1 is the name of the template and the second one determines if it is on or off maybe? That is just my guess as only part of the code was available. This is just for study purposes, Based on something like below, what kind of code could be wrote for that function to show a certain area of the page? I am thinking about doing some sort of template system for the learning experience which is why I do not want to use smarty.

Please give me your ideas on how to do this?

<php
tpl_set('home_announcement', $home_announcement_tpl);
tpl_set('hide_announcement_bit', $HIDE_ANNOUNCEMENT_BIT);
tpl_set('orientation_info', $orientation_info);
tpl_set('feed_stories', $feed_stories);

if ($show_friend_finder && (user_get_friend_count($user) > 20)) {
    tpl_set('friend_finder_hide_options', array('text' => 'close', 'onclick' => "return clearFriendFinder()"));
}

//end of page has this
render_template($_SERVER['PHP_ROOT'] . '/html/home.phpt');
?>
  • 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-12T12:08:11+00:00Added an answer on May 12, 2026 at 12:08 pm

    Looking at the code snippet you paste, I would assume tpl_set sets specific variables in the template – such as setting the value of feed_stories template variable to content of $feed_stories. In the end, the render_template function chooses a template and renders it.

    Since you say you want to do a template system yourself, here’s a few pointers:

    The most basic template can be a PHP file, such as this:

    //mytemplate.php
    <h1><?php echo $title; ?></h1>
    <p><?php echo $content; ?></p>
    

    Then, you could utilize this like so

    $title = 'some title';
    $content = 'Hello world';
    require 'mytemplate.php';
    

    This is the simplest way to have templates in PHP. You can optionally wrap the above process into a class or set of functions, so you get a bit cleaner interface.

    An approach taken by various template engines, such as Smarty, is to have a custom syntax. As you may know, Smarty lets you use {$foo} to echo variables in templates. The way this works, is that you first provide Smarty with values for each variable in your template. When rendering the template, Smarty does a search and replace in your template, replacing Smarty-syntax with your values.

    (It doesn’t actually do that – it converts it first into PHP code and caches it to make it faster, but the basic idea is that.)

    Hope this helps.

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

Sidebar

Related Questions

I have a problem with going over an if statement that the code should
this is probably going over the top, but I was after a function that
Been going over my predecessor's code and see usage of the request scope frequently.
When I iterate over the values or keys are they going to correlate? Will
When creating an index over a column that is going to be UNIQUE (but
I am going over my code and trying to get a handle on proper
Going over the Facebook API and I'm a bit confused on the right approach.
I was going over a piece of code, and i came across this regular
So I'm working on some code (going over a practice exam for a course
Going over some old code <!--- RANDOMLY DECIDE IS THIS PERSONS A WINNER 1

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.