Get started with PHP-Fusion

  1. PHP-Fusion Support Forums
  2. Development & Design
  3. Roadmap

Please Read - Design Issues Roadmap 9.02 Final Template Function Changes

[Development Team Access] All Roadmap items end up here for discussions.

1 Reply 430 Views Last Updated on 3 months ago

Chan


Super Admin

#1

Posted 3 months ago

I'm proposing a change to all Template for Core in PHP-Fusion 9.

Only a handful of people in our designing community knows PHP. So, in order to fix this reality and to help a broader sense and range of community users, what I will be introducing here is to Drop all PHP and make it HTML. This is in line of a betterment for everyone.

If you have modification work, it is necessary to alter to your needs. I'm renaming the functions in order to grab your attention in attending this matter.

To show you the change, I will take a practical example.

In PHP-Fusion 9, the Template for User Registration Form is currently:

Code Gist: Download source  


function render_userform($info) {
        $open = "";
        $close = "";
        $tab_title = array();
        /**
         * $info['sections'] are category pages
         */
        if (isset($info['section']) && count($info['section']) > 1) {
            foreach ($info['section'] as $page_section) {
                $tab_title['title'][$page_section['id']] = $page_section['name'];
                $tab_title['id'][$page_section['id']] = $page_section['id'];
                $tab_title['icon'][$page_section['id']] = $page_section['icon'];
            }
            $open = opentab($tab_title, $_GET['section'], 'user-profile-form', TRUE);
            $close = closetab();
        }
        echo $open;
        if (empty($info['user_name']) && empty($info['user_field'])) {
            echo "<div class='well text-center'>\n";
            global $locale;
            echo $locale['uf_108'];
            echo "</div>\n";
        } else {
            echo "<!--editprofile_pre_idx-->";
            echo "<div id='register_form' class='row m-t-20'>\n";
            echo "<div class='col-xs-12 col-sm-12'>\n";
            // form tag
            if (!empty($info['openform'])) {
                echo $info['openform'];
            }
            // user name field
            if (!empty($info['user_name'])) {
                echo $info['user_name'];
            }
            // user email field
            if (!empty($info['user_email'])) {
                echo $info['user_email'];
            }
            // hide email options field
            if (!empty($info['user_hide_email'])) {
                echo $info['user_hide_email'];
            }
            // avatar field
            if (!empty($info['user_avatar'])) {
                echo $info['user_avatar'];
            }
            // password field
            if (!empty($info['user_password'])) {
                echo $info['user_password'];
            }
            // admin password field
            if (!empty($info['user_admin_password']) && iADMIN) {
                echo $info['user_admin_password'];
            }
            /**
             * These are Custom User Fields.
             * It is possible to run conditions to add custom html
             * print_p($info['user_field'])
             */
            if (!empty($info['user_field'])) {
                foreach ($info['user_field'] as $fieldCat_ID => $fieldCat_Data) {
                    if (!empty($fieldCat_Data['title'])) {
                        echo $fieldCat_Data['title'];
                    }
                    if (!empty($fieldCat_Data['fields'])) {
                        foreach ($fieldCat_Data['fields'] as $fields) {
                            echo $fields;
                        }
                    }
                }
            }
            // grecaptcha, captcha, etc
            if (!empty($info['validate'])) {
                echo $info['validate'];
            }
            // license agreement
            if (!empty($info['terms'])) {
                echo $info['terms'];
            }
            // button to save
            if (!empty($info['button'])) {
                echo $info['button'];
            }
            /**
             * Adding custom html codes here is possible
             */
            // closeform tag
            if (!empty($info['closeform'])) {
                echo $info['closeform'];
            }
            echo "</div>\n</div>\n";
            echo "<!--editprofile_sub_idx-->";
        }
        echo $close;
    }


I see many non PHP programmers designer run away. Don't need, read on..

Yes, the code above proved to be too complex for quite a large number of groups and that is why prevented theme customization in many case.

So for the past month, I have been revising my drawing board back and forth for a lot of times to make the best method and talked to few colleagues close working with me on my IM about ideas.

And after many thoughts, a perfect model is made. What i need was:

1. Support HTML
2. Support PHP
3. No default PHP
4. Database Friendly Template.

Here is solution and what will change:

Code Gist: Download source  


/**
     * Registration Form Template
     * The tags {%xyz%} are default replacement that the core will perform
     * echo output design in compatible with Version 7.xx theme set.
     *
     * @param $info - the array output that is accessible for your custom requirements
     *
     * @return string
     */
    function display_register_form(array $info = array()) {
        ?>
        <!---HTML---->
        {%tab_header%}
        <!--editprofile_pre_idx-->
        <div id='register_form' class='row m-t-20'>
            <div class='col-xs-12 col-sm-12'>               
               {%user_name_field%}
               {%user_email_field%}
               {%user_hide_email_field%}
               {%user_avatar_field%}
               {%user_password_field%}
               {%user_admin_password_field%}
               {%custom_fields%}
               {%captcha_fields%}
               {%eula%}
               {%post_button%}
           </div>
       </div>
       {%tab_footer%}
        <!---//HTML---->
       <?php
    }


The advantages from this change:
1. Buffer based render. You most likely will not have a "only-show-page-when-script--finish---loading" kind of problem. Optimization.
2. Echo based instead of string based. Compliant with render_news() etc. of Version 7 Templates AND is HTML.
3. Core scripts will have 0 dependencies against template. It's the other way round.
4. Will pave way to a new breakthrough. DB Oriented BBCode Template.(Essential is Point 3 is achieved).
5. All you ever need is HTML and CSS.

Impact:
We will escalate modding audience to beginner HTML people. Mind the macro {%tags%}. These must be preserved as they are targeted for replacement.

Documentation will cover all the tags and what it means.

Standard code for callback in All Infusions/Core Pages:
Code Gist: Download source  


/*
         * Output Handling and Parse Info (2-in-1)
         */
        ob_start();
        display_register_form($this->info);
        //$template = ob_get_clean();
        echo strtr(ob_get_clean(), [
                '{%tab_header%}'                => isset($tab_title) ? opentab($tab_title, $_GET['section'], 'user-profile-form', TRUE) : '',
                '{%user_name_field%}'           => $this->info['user_name'],
                '{%user_email_field%}'          => $this->info['user_email'],
                '{%user_hide_email_field%}'     => $this->info['user_hide_email'],
                '{%user_avatar_field%}'         => $this->info['user_avatar'],
                '{%user_password_field%}'       => $this->info['user_password'],
                '{%user_admin_password_field%}' => $this->info['user_admin_password'],
                '{%custom_fields%}'             => $fields_,
                '{%captcha_fields%}'            => $this->info['validate'],
                '{%eula%}'                      => $this->info['terms'],
                '{%post_button%}'               => $this->info['button'],
                '{%tab_footer%}'                => isset($tab_title) ? closetab() : ''
            ]
        );


For all existing custom work variations
Your template is supported because $info still preserved.
What you need to do is to rename your function name to the new ones, and until you do so, your site will go back to core default. So it is safe to upgrade still.
In order for your custom work to back to being used, you need to review the changes. Fortunately, it is ultra simple of a change.

You do not have to change your template innards if you already have custom work based on it. Just rename function after reviewing your changes.

- See there is an $info parameter. Those are for the customization. If you print_p($info); you will have them supported as well.

This template method will support both PRO and BASIC. It's an easy, simple, professional template framework without relying on external repositories.

The implementation will take change gradually this week onwards.

Any ideas, notes or comments, please reply on the thread.

Posts: 3397

Joined: 25/09/2007

Chan


Super Admin

#2

Posted 3 months ago

Approaching final model for stable. I'm doing system health checks and making last increments and documentation guides.

Some RC5 updates...
--------------------------------
To my knowledge, openGraph is Incrementing.
Search has been totally rewritten. Latest being a search engine class and Is fully templatable.
Error page template adjusted to HTML.
Bug fixed error loggers.
Token will recycle only for administrators by default
Member administration beefed up like marshmallows on fire. Totally rewritten from ground up.
What else this week are some minor code cleanups.

We will first change HTML template will change for core applications as notified earlier. They will be escaped and run pure HTML unless you know what you're doing, php variables are also available. It's a 2-in-1 solution and the most powerful type I can think of that serves all audiences. I will document it as I go. Here is the write ups:

https://github.com/php-fusion/PHP-Fusion/tree/9...e/Template

These contents will move to this site when we are ready with the new platform.

I wrote it as layman as possible. Just read them if you want to customise your web apprearance.

Posts: 3397

Joined: 25/09/2007

Jump to Forum:
10 users are online
0 member and 10 guests