Hongmu Notes
Home Program Notes How to make administrator login visible on Emlog?
Program Notes emlog

How to make administrator login visible on Emlog?

How to make administrator login visible on Emlog?

After researching EMLog and downloading a template, I discovered that there is no logged-in visibility feature during use!

I want the administrator login to be visible!

So, I checked the official documentation:

Constant that can be used directly

Variables, Constantstypeexplain
Option::EMLOG_VERSIONconstantGet the current EMLOG version number
ROLEconstantCurrent user role (user group): admin (Administrator), writer (Registered User), visitor (Guest)
ROLE_ADMINconstantAdmin
ROLE_WRITERconstantWriter – Registered User
ROLE_VISITORconstantVisitor
UIDconstantactive userUID
BLOG_URLconstantFull website address
ISLOGINconstantWhether the user is logged in: true – logged in; false – not logged in.

Based on the above documentation, I wrote some code!

Primarily enables login visibility on content pages!

PHP code modification

Find article templateecho_log.phpdocument.

Open and locate the variable that holds the output article content.$log_content

Edit:

<?php
if(ROLE == 'admin'){
    echo styleContent($log_content);
}else{
    echo hiddenContent($log_content,'<div class="hiddenContent">涉及到机密,管理员可见</div>');
}
?>

ad1a1b7183154040

CSS code beautification

.hiddenContent{
    font-size: 15px;
    border: 1px dashed red;
    color: red;
    text-align: center;
    padding: 25px 0;
}

ad1a1b7183154125

New PHP functions

The template is located at:module.phpAdd the following two functions to the document:

// 处理内容,直接输出
function styleContent($string){
   $string = str_replace(array('[hide]','[/hide]'),'',$string);
   $string = str_replace("<br />","</p><p>",$string);
   echo $string;
}
// 隐藏内容,不可见
function hiddenContent($string, $prompt) {
    $pattern = "/\[hide\](.*?)\[\/hide\]/";
    $replacement = $prompt;
    $result = preg_replace($pattern, $replacement, $string);

    return $result;
}

usage mode

When editing an article in the backend, use this to hide the content you no longer wish to display.[hide][/hide]Just put it in parentheses!

微信赞赏

WeChat

支付宝赞赏

Alipay

✍️ Author: Hong Mu

webmaster · Thanks for reading, stay tuned for more exciting content

Author homepage View home page →

Related articles

Emlog enables automatic saving when editing articles.

Emlog enables automatic saving when editing articles. Program Notes emlog

The automatic save feature allows you to automatically save your edits when you publish an article – it doesn't generate any extra IDs or drafts! When you click the "Auto Save" button, the page will be automatically submitted and saved without interrupting your editing process! The advantage is that you can save your article at any time; if a power outage or network disruption occurs and your changes aren't saved, you might be in for a real headache! Let's get started with the tutorial! Step 1: Open /admin/views/artic...
👁 244
EMLOG backend editor – Set text size

EMLOG backend editor – Set text size Program Notes emlog

When editing text in EMLOG, the font size displayed is too small, making it very uncomfortable to read; if left unchanged, the text is practically impossible to read! To set the font size to 16px, you can modify the following code: Step 1: Open the `admin/views/article_write.php` file, and in the initialization section of both `Editor` and `Editor_summary`, locate the `path:` line...
👁 201
Change article line breaks in EMLog to <p> tags.

Change article line breaks in EMLog to <p> tags. Program Notes emlog

The new version of EMLOG is still unfamiliar to me – the editor still has a ton of issues! However, since I'm not very familiar with JavaScript, I've simply modified the line breaks using PHP! Find your article page template (e.g., `echo_log.php`) and modify the variable used for outputting your articles: `&lt;? $log_content = str_replace(&quot;&lt;br/&gt;", &quot;&lt;/p&amp;gt;...`
👁 191
When editing articles in the EMLOG backend, automatic saving and display of word count statistics are enabled.

When editing articles in the EMLOG backend, automatic saving and display of word count statistics are enabled. Program Notes emlog

The specific modifications are shown in the figure below: This shows exactly how many seconds have been saved! It also displays the number of words in the article, making it very convenient for users to review their own content! Modification tutorial: Open the file `/admin/views/article_write.php`, and locate the code snippet: `<label>Article Summary:</label><%/label>` – this is approximately 18 lines of code. Add the following code snippet above this section: `<span i...`
👁 260
EMLog Pro – Happy Crack Version – For learning, sharing, and use.

EMLog Pro – Happy Crack Version – For learning, sharing, and use. Program Notes emlog

This website uses the WordPress platform; emlog was only temporarily used for learning and sharing purposes. Recently, I remembered using the emlog software to write a blog before – it worked quite well – so on a whim, I downloaded and started using it! However, there's a so-called paid version available! So, I searched online and found a cracked version of the software. Driven by my desire to learn, I gave it a try – and the results are as follows: The performance is excellent! In fact, the emlog source code is open-source, and...
👁 1587
EMLOG Pro Registration Code "Cracking" Tutorial (What should users do if the official or free version of EMLOG suddenly becomes unavailable?)

EMLOG Pro Registration Code "Cracking" Tutorial (What should users do if the official or free version of EMLOG suddenly becomes unavailable?) Program Notes emlog

Preface: A tutorial on "cracking" the EMLOG Pro registration code – why use quotation marks for the word "cracking"? Because EMLOG is fully open-source software; anyone can download and modify it freely. Since it's open-source, the concept of "cracking" doesn't really apply. Main text: What should users do if the official EMLOG version or the free EMLOG version suddenly disappears? What if your EMLOG Pro cannot connect to the server...
👁 1264

Recommended reading

(PC + WAP)苗木与草坪种植类网站 – PBootCMS template; Green Agriculture Website Source Code Download – 0884

(PC + WAP)苗木与草坪种植类网站 – PBootCMS template; Green Agriculture Website Source Code Download – 0884 Practical Collection pbootcms Template

A PbootCMS template designed for websites specializing in nursery stock and lawn planting as well as green agriculture, supporting both PC and mobile access. Its natural design style effectively showcases nursery breeding operations, lawn cultivation facilities, and agricultural projects. This template helps agricultural enterprises build their online brand identity and expand their sales channels for agricultural products or nursery stock. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction password...
👁 62
(Adaptive Mobile Version) pbootCMS responsive tourism company website template – Blue widescreen travel agency website source code download – 0213

(Adaptive Mobile Version) pbootCMS responsive tourism company website template – Blue widescreen travel agency website source code download – 0213 Practical Collection pbootcms Template

This adaptive mobile-friendly PbootCMS responsive tourism company website template features a blue widescreen design. Its fresh and sophisticated aesthetic makes it ideal for showcasing travel itineraries, attraction descriptions, and travel guides. It helps travel agencies or tourism platforms attract online visitors and enhance their brand awareness. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.cn...
👁 31
Responsive leather goods外贸 enterprise website template – 1096

Responsive leather goods外贸 enterprise website template – 1096 Practical Collection Yiyou template

An eyouCMS responsive website template designed specifically for leather goods export enterprises. Its modern, international design style effectively showcases leather products, brand identity, export advantages, and global market presence. This template helps leather brands enhance their brand image in the international market and secure overseas orders. Template Display | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for YououCMS | YououCMS...
👁 56
Custom Holiday Gift Ordering Website Template 0393

Custom Holiday Gift Ordering Website Template 0393 Practical Collection Yiyou template

This EyouCMS template is ideal for the holiday gift and custom gift industry. Its sophisticated, high-end design style is perfect for showcasing gift products, customisation services, brand stories, and holiday promotions. It enables gift customization brands to showcase their products online and attract both corporate and individual clients. Template Preview | Installation Instructions | Website Backend: /login.php | Username: admin | Password: admin | Related Articles: Summary of Common Installation Issues for EyouCMS | EyouCMS...
👁 59
(Adaptive mobile version) Responsive cleaning products website – PBootCMS template; Download source code for a cleaning equipment trade agency website – 0885

(Adaptive mobile version) Responsive cleaning products website – PBootCMS template; Download source code for a cleaning equipment trade agency website – 0885 Practical Collection pbootcms Template

A responsive PbootCMS website template designed for trade agency businesses specializing in cleaning products and equipment, compatible with both PC and WAP devices. Its clean and practical design is ideal for showcasing cleaning tools, equipment, and agency-branded products. This template helps cleaning product companies showcase their product lines online and expand their channel-based customer base. Template Display | Installation Instructions | Website Backend: /admin.php | Username: admin | Password: admin | Extraction Password: www.4s5.c...
👁 47