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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:44:13+00:00 2026-05-27T15:44:13+00:00

I have a question regarding a HTML template.. I have create a template function

  • 0

I have a question regarding a HTML template.. I have create a template function which replace markers in a HTML template with content from a database..

   /***********************************************************
    * TemplateGenerator will match markers in a defined html
    * template and replace them with corresponding data
    * i.e. ###MARKER_1### in html template will be replaced
    * with data in the ###MARKER_1### array key defined 
    * in GetMarkers function.
    *
    * @param string  | The html template
    *                  The template can contain all the html the  
    *                  layout needs - matched markers will be replaced.
    ************************************************************/   
    public static function TemplateGenerator($template) {

        /* Get content from the html template */    
        $data = file_get_contents($template);

        if(isset(self::$newmarkers)) {

            /**************************************************
            * Match each key in $this->markers array 
            * and replace with the correct value
            ***************************************************/ 
            foreach(self::$newmarkers as $key => $value) {
                    if(preg_match("/". preg_quote($key) ."/", $data, $matches)) {
                        $data = str_replace($key, $value, $data);
                } else { 
                    $data = $data;
                }
            }

            return $data;

        } else { 
            if(!empty($data)) { 
                echo $data;
            } else { 
                die("Der er sket en fejl med genereringen af siden");
            }
        }
    }

I am using this function in a php newsletter application.. This works almost perfectly, but when I created the application I didn’t taking into account the possibility of editing the letter (why, I don’t know).

I have a HTML template (standard.html) with input fields to create a newsletter.

<h1 style="background-image: url(gfx/icons/new.png); background-position: left; background-repeat: no-repeat;">Opret nyhedsbrev - ###THETMP###</h1>

<form action="index.php?page=create" method="post" enctype="multipart/form-data">
    <label for="letter_headline">Overskrift:</label> <input type="text" name="letter_headline" id="letter_headline" value="" /><br />
    <label>Modtagere: </label> <select name="recievers[]" multiple="multiple" size="5">###RECS###</select><br />
    <label>Billede</label> <input type="file" name="letter_image[0]" id="letter_image" value="" /><br />
    <label for="letter_content">Indhold</label> <textarea name="letter_content" id="letter_content" cols="50" rows="15"></textarea><br />
    <label for="letter_link">Link</label> <input type="text" name="letter_link" id="letter_link" value=""  /><br />
    <label for="letter_link_txt">Linktekst</label> <input type="text" name="letter_link_txt" id="letter_link_txt" value="" /><br />
    <input type="hidden" name="template_to_use" value="standard.html" />
    <input type="submit" value="Opret nyhedsbrev" name="create" />
</form>

When I select that I want to create a standard newsletter, the TemplateGenerator function will output this template with i.e. a recievers list in the marker ###RECS###.

I have a table called newsletter_fields that have the following columns:

field_uid | field_name | field_content

where field_name will contain the name of the input field, i.e. letter_headline and field_content will have the content that was written into the input field when the letter was created, i.e. “This is a headline”.

My question is if I can use that same HTML file in a editletter function that will replace only the value="" in the input fields with i.e. value="This is a headline" in the letter_headline input.

  • 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-27T15:44:14+00:00Added an answer on May 27, 2026 at 3:44 pm

    You are taking it from the wrong side.

    If you have your values ALWAYS filled with markers, you can use the same template both for adding and editing, filling markers with empty strings for the latter case.

    However, the whole idea of such a template is wrong.
    A template engine should be able to implement basic programming logic, like loops, conditions and includes.
    Otherwise there will be no good from the template at all and you’ll end up with HTML in your code (like you have already in the ###RECS### marker).

    PHP based template is going to be way more convenient and I’d advise to strat using it instead of this one

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

Sidebar

Related Questions

I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
hello everybody i have a question regarding strip_tags function. i have an html document
I have question regarding the use of function parameters. In the past I have
I have a question regarding dependency injection. say i want to create a class
I have a question regarding static function in php. let's assume that I have
I have two questions regarding to html table layout. First I will provide some
I have a question regarding a call to a function that takes quite a
I have a question regarding the online Google cloud lab @ http://code.google.com/apis/sql/docs/developers_guide_java.html at the
My question is regarding JavaScript Closures and the Eval() function. I have some code
I have questions on preventing XSS attacks. 1) Question: I have an HTML template

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.