UAP 4 Documentation - BuildingaPage

Welcome to UAP Docs - BuildingaPage

Building a Page

This tutorial will explain how to build your own custom page for your UAP install. If you are new to UAP, please read MVC Explained to better understand how an MVC works before continuing.
In this tutorial we will build a Contact page. The contact page is already built into UAP, but can be easily edited.
First we will add the function called to the Home Controller located in /app/Controllers/Home.php

    /* Contact Method */
    public function Contact(){
        $data['title'] = $this->language->get('contactText');
        $data['bodyText'] = $this->language->get('contactMessage');
        /** Check to see if user is logged in **/
        if($data['isLoggedIn'] = $this->auth->isLogged()){
          //** User is logged in - Get their data **/
          $u_id = $this->auth->user_info();
          $data['currentUserData'] = $this->user->getCurrentUserData($u_id);
          $data['isAdmin'] = $this->user->checkIsAdmin($u_id);
        /** Get Data For Member Totals Stats Sidebar **/
        $onlineUsers = new MembersModel();
        $data['activatedAccounts'] = count($onlineUsers->getActivatedAccounts());
        $data['onlineAccounts'] = count($onlineUsers->getOnlineAccounts());
        Load::View("Home::Contact", $data, "Members::Member-Stats-Sidebar::Right");
The above contact method does not collect any data from the user. It is set-up to just display information.

It pulls current user's information if they are logged in, and pulls stats from database for sidebar.

The Load::View Function then loads the view file to format the information collected.
This tutorial will not contain any new models. So we will save that for another tutorial.
Now we create a View. The View is located in /app/Views/Home/Contact.php

* Contact View
* UserApplePie
* @author David (DaVaR) Sargent <>
* @version 4.0.0
use Libs\Language;
<div class="col-lg-8 col-md-8 col-sm-8">
	<div class="card mb-3">
		<div class="card-header h4">
			<h1><?php echo Language::show('uap_contact', 'Welcome'); ?></h1>
		<div class="card-body">
			<p><a href="../Home/" class="btn btn-primary btn-sm"><?php echo Language::show('openHome', 'Welcome'); ?></a>
			<a href="../About/" class="btn btn-primary btn-sm"><?php echo Language::show('openAbout', 'Welcome'); ?></a></p>
The above code is set-up to use the language file to pull data but you can just remove them and use basic html.
Now that we have the Contact files setup and ready to go, we need to let the system know they exist. Without the route set-up the page will not work because there is no way to find the files without it.

Open the Admin Panel and click System Routes. The system will check for any new Methods within all files in the Controllers folder. It also checks for new Methods within all files in Plugins Controllers folders. If it detects a new Method, you should see a notification listing what it found. By default the Url name will be same as the detected method name. The url may be changed to whatever you like in the future.

You should now be able to open and the contact page should display.
You can edit the /app/Templates/Default/Header.php file to add a link to your Contact page. If you have any questions please use the forums below.
- Can't find what your looking for? Please use Forum.

UAP 4 Documentation - BuildingaPage

Last Reply
Forum Permissions
You cannot post in this forum.
You cannot moderate this forum.
You cannot administrate this forum.