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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:14:16+00:00 2026-05-15T11:14:16+00:00

I have been writing some code that creates a generic blog. Its features are

  • 0

I have been writing some code that creates a generic blog.

Its features are simple, create a post, edit and delete the post and allow comments.

I am trying to write it so that it is very easy to write plugins for, however Im not sure on the best approach.
Some of my ideas:

  1. Have the plugin author write a short script called e.g “config” in which they have an array that has the application(e.g frontend, admin etc), the module(e.g blog, profile etc) and the action(s)(e.g create, edit etc) that thier plugin affects, then include the plugin files when the correct action is run.

    //example array in config.php:
    array(
      'application' => 'admin',
      'module'      => 'blog',
      'action'      => array('create','edit')
    );
    
  2. add strings into the views code such as “{form-extras}” and have the plugin author say which string there code will replace. Then use str_replace to replace the {xxx} with the plugin code.

    #example code in blog_form.php
    <input type="text" name="blog_title" />
    <input type="text" name="blog_text" />
    {form-extras}
    
    #example code in plugins config.php
    array(
      'replace' => array('form-extras')
    );
    

Both of these ideas are pretty rubbish and very limited in their use but I am struggling to come up with an better ideas.

I’m not sure how much info about my code people need but the basic dir structure is simple, below is an example:

apps //applications
  frontend  //app name
    modules
      blog
        views
          index.php  //list blogs
          new.php //create new blog post
        actions.class.php
  admin
    modules
      blog
        views
          index.php  //list blogs
          new.php //create new blog post
        actions.class.php
lib //library of classes like database class
plugins //where plugins will hopefully be installed
web //where the site runs e.g index.php, all the css and js

The Question

Does anyone know of any tutorials/articles on making code easy to write plugins for, or does anyone have any tested methods that I could apply?

Regards

Luke

  • 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-15T11:14:16+00:00Added an answer on May 15, 2026 at 11:14 am

    Before you start thinking about how to make the plugins system, you have to define what exactly a plugin is for you application, what the plugins can do and what data the plugins will be able to access (for example, posts table but not users table).

    Then, take a look at Drupal, i guess it’s module system based on hooks is really powerfull and ‘simple’ to use for developers.

    Basically, the idea is that when a module or plugin is installed, everythings you do on your ‘core’ code, search if there is some module/plugins hooked to that action.

    Example:

    //your code
    $modules_enabled = array('foo', 'bar');
    //example action, lets say insert a new blog post. Obviously, nothings prevent you
    //to do that in OOP style (i'd never really understood why drupal is almost all procedural).
    function create_new_post($modules_enabled, $other_args){
        //looks if some modules need to be called before create the blog post
        foreach($modules_enables AS $module){
            if(function_exists("after_create_new_post_$module")){
                $func = "before_create_new_post_$module";
                $func($params);
            }
        }
        //do your stuff here
        //looks if some modules need to be called after the post is been created
        foreach($modules_enables AS $module){
            if(function_exists("after_create_new_post_$module")){
                $func = "after_create_new_post_$module";
                $func($params);
            }
        }
    }
    
    //the module file should look like $hooks_name . $module_name:
    function after_create_new_post_foo($args){
        //do your job
    }
    

    This is a very very sintetic example (and doesnt work!), but should give you the idea.

    The only problem here comes with the args that you pass to each hook_function, that have to be documented really good, however the documentation is important whatever path you’ll choose.

    Some reference: Drupal hooks, hook_insert

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

Sidebar

Related Questions

I have been writing some code to create a byte array I will be
I have been messing around with writing some stored procedures in .NET code with
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside
I have been writing some C# code for a training exercise, in which I
I have been writing some rspec tests, and right now I want to verify
I am trying to learn more about the DOM and have been writing some
I have been given the task of re-writing some libraries written in C# so
I have been writing unit tests using NUnit and Moq with my Silverlight code
I have some code like the following that I'm running in a debugger in
I'm doing some relatively simple I/O in Java. I have a .txt files that

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.