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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:17:26+00:00 2026-05-25T17:17:26+00:00

I designed two forms of plugin for my CMS but I have problem with

  • 0

I designed two forms of plugin for my CMS but I have problem with one of them. The first one which will be implemented in the templates, it’s cool there is no problem with that. But the second one which is for my admin area, I designed it in this way.

First I defined an instruction file which is a text file with this content:

REPLACE_INLINE("sample.php","//Echo/*","//Echo*/","echo \"test\"","echo \"new test\"");

In my plugin install function I split up these arguments and I go to do them and at last I save the new content. It works fine but I want to know, is it the right way of designing plugins? I think It’s not and for that I posted a topic.

By the way my sample.php file which I assume that It’s one of my CMS’s source files contains this data:

<?php
  function showText(){
    //Echo/*
    echo "test";
    //Echo*/
  }
?>

And one thing else, If I do this, maybe next time another plugin wants to interact some data with the echo “test”; line And if it wouldn’t be like the main template then we’re gonna boom ! crash.

The sample.php data after plugin installation:

<?php
  function showText(){
    //Echo/*
    echo "new test";
    //Echo*/
  }
?>
  • 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-25T17:17:27+00:00Added an answer on May 25, 2026 at 5:17 pm

    Instead of having to textually replace content, you should either go with an object-oriented architecture where subclasses can overwrite showText (and/or call the old implementation) or use callbacks, like this:

    $plugin_callbacks = array();
    function showText() {
      $text = 'test';
      foreach ($plugin_callbacks as $cb) {
        $text = call_user_func($cb, $text);
      }
      echo $text;
    }
    
    $plugin_callbacks[] = function($text) {
      return 'new text';
    }
    $plugin_callbacks[] = function ($text) {
      return '<b>' . $text . '</b>';
    };
    

    However, as you can see, this can get messy soon. Therefore, unless there is a very limited number of callbacks, use an object-oriented design (which will require you to have an instantiation factory where plugins can register and determine which type the echoObject will be).

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

Sidebar

Related Questions

I have two simple forms designed in maximized view. when switching between them (showing
I have an (ASP.NET 3.5) intranet application which has been designed to use forms
I have created two forms in the designer, formA and formB, one is a
I have a poorly designed database. One of the most important tables has 11,000+
On a form designed with Qt Designer, I have two QGroupBoxes with a bunch
I have two processes which exange messages each other. Process A is a normal
I have a two windows forms classes, a base class and a derived class.
Trying to choose a PHP open source CMS into which I will integrate an
I have designed a long form around two pages. After the user submits the
I have designed database tables (normalised, on an MS SQL server) and created a

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.