# 관리자 페이지 추가하기

## 📌 요구사항 및 분석

* [관리자 메뉴 추가하기](/guide/tuning-example/add-menu.md) 에서 추가한 3차 메뉴인 `관리자 > 기본설정 > 메뉴 정책 > 메뉴 관리` 에 접근할 수 있는 페이지를 만들고자 함

## 📝 개선안 정리

* <https://gdadmin.example.godomall.com/policy/menu\\_management.php&#x20>;
* 위 URL로 접근 가능한 컨트롤러 추가

## 🛠️ 커스터마이징 진행

### 📌 Controller 추가 (방법 1) <a href="#controller-1" id="controller-1"></a>

`module/Controller/Admin/Policy` 폴더에 추가할 페이지의 컨트롤러 파일(`MenuManagement.php)` 을 추가합니다.

#### 사용자 정의 `Controller` 소스 내용

```php
<?php

/**
 * Namespace는 Controller\폴더명\폴더명으로 작성합니다.
 */
namespace Controller\Admin\Policy;

/**
 * Classname는 파일명과 동일해야 합니다.
 * \Controller\Admin\Controller라는 부모 클래스를 상속받습니다.
 */
class MenuManagementController extends \Controller\Admin\Controller
{
    /**
     * Class Methods로 반드시 index()를 포함해야 합니다.
     * 추가로 Methods 만들어 동일 파일내에서 사용이 가능합니다.
     */
    public function index()
    {
        try {
            // 관리자 페이지 좌측 메뉴 불러오기
            $this->callMenu('policy', 'menu', 'menu_management');
            
            $setData = 'Hello World!';
            $this->setData('setData', $setData);

        } catch (\Exception $e) {
            throw $e;
        }
    }
}

// PHP 소스 코드만 포함된 경우 ?> 를 생략합니다. (PSR0 표준)
```

### 📌 Controller 추가 (방법 2) <a href="#controller-1" id="controller-1"></a>

* 액션 처리와 같이 스킨으로 전송할 필요가 없는 경우 `index()`메소드에서 `exit();` 처리로 강제 종료합니다.
* 고도몰에서는 `SomePsController`라는 이름으로 사용하고 있습니다. form으로 넘겨서 데이터를 가공하기 위한 목적으로 사용됩니다.

#### 사용자 정의 `Controller` 소스 내용

```php
<?php
namespace Controller\Admin\Policy;

class MenuManagementController extends \Controller\Admin\Controller
{
    public function index()
    {
        try {
            $setData = 'Hello World!';
            echo $setData;
            exit();
    
        } catch (\Exception $e) {
            throw $e;
        }
    }
}
```

### 📌 관리자 스킨 추가 <a href="#controller-2" id="controller-2"></a>

* `admin/policy/` 폴더 하위에 추가할 `HTML` 파일을 추가합니다.
* `gdadmin.example.godomall.com/policy/menu_management.php` 경로의 사용자 페이지를 추가한다면 `admin/policy/` 폴더 아래 `menu_management.php` 파일을 추가합니다.

#### `Controller`에서 선언한 `setData` 사용하기

{% code title="menu\_management.php" %}

```html
<p><?=$setData;?></p>
```

{% endcode %}

## 🔖 결과 확인

<figure><img src="/files/0HbvBDZm3ynXCILvAabq" alt=""><figcaption></figcaption></figure>

![](http://localhost:63343/markdownPreview/61509271/fileSchemeResource/d4efec3275118710f6aa2be05b7ef1e5-admin_order_skin_create_view.jpg?_ijt=ck9ogtp4gbjoonhj6jtngrd1ie)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://devcenter-help.nhn-commerce.com/guide/tuning-example/add-admin-page.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
