Mecha CMS

Add extra functionality to the core engine.

User

Rich user data.

File 

All you have to do after installing this extension is to create a page file in the .\lot\user folder. Name the page according to the user name you want. For example, here I will create user data with the name @‌ta-tau-taufik:

.\
└── lot\
    └── user\
        └── ta-tau-taufik.page

And the following is the content of the file:

---
'$': Taufik Nurrohman
type: Markdown
status: 1
...

I am the main author of [this site](https://mecha-cms.com).

Page 

User profile page can be accessed via the https://mecha-cms.com/user/ta-tau-taufik link. To go to the log in page, remove the user name from the link:

https://mecha-cms.com/user

Note: If .\lot\user\ta-tau-taufik\pass.data file does not exist, then the password field will function as a password generator. You can type any password in it and pass.data file will be created automatically.

Constant 

This extension will add a folder called user in the .\lot folder, which will also automatically add a constant named USER.

USER

Method 

There are some methods added to the default classes:

Is User 

Is::user(string $key = null, $fail = false): User | $fail;

Example:

Check whether a user is logged in:

if (Is::user()) { … }

Check whether user @‌ta-tau-taufik is logged in:

if (Is::user('ta-tau-taufik')) { … }

Get Users 

Get::users(string $folder = USER, …, $sort = [1, 'path'], …): Anemon;

Function arguments are the same as function Get::pages(), except the $folder parameter that uses USER constant value by default, and the $sort parameter that uses path as the default sort key instead of time.


Result 

Without User Extension 

The page in .\lot\page\test-page.page:

---
title: Page Title
author: Taufik Nurrohman
...

Page content.

To get the author data:

<?php echo $page->author; ?>

With User Extension 

The page in .\lot\page\test-page.page:

---
title: Page Title
author: '@ta-tau-taufik'
...

Page content.

The user file in .\lot\user\ta-tau-taufik.page:

---
'$': Taufik Nurrohman
link: 'http://example.com'
...

Page content.

To get the author data:

<a href="<?php echo $page->author->link; ?>" id="<?php echo $page->author->key; ?>">
  <?php echo $page->author; ?>
</a>

Or:

<?php echo $page->author; ?>

Dependency 

Extension 

0 Comments

No comments yet.