by Razor12345 Fri 13 Oct - 10:37
Good morning!
1)
AP - General - Categories and forums If you already have a category (not a forum!) for guests - edit it. If not, create one
Category name: enter the following in this field
- Code:
<div class='guest__category'>NAME CATEGORY</div>
NAME CATEGORY - Your title for this category.
Save.
Next, create forums in this section for guests.
2)
AP - Display - Colors&CSS - CSS StylesheetInsert this code:
- Code:
.forumline {
visibility: hidden;
}
Save.
3)
AP - Modules - Javascript codes management - Create a new JavascriptTitle: any
Placement: In all the pages
Javascript Code: - Code:
$(document).ready(function() {
window.addEventListener('DOMContentLoaded', function() {
const logOut = document.querySelector('#logout');
const forumCategories = document.querySelectorAll('.forumline');
const userNick = window._userdata.username;
const adminNick = 'Admin';
if (userNick === adminNick) {
forumCategories.forEach((item) => {
item.style.visibility = 'visible';
});
} else {
forumCategories.forEach((item) => {
if (item.querySelector('div.guest__category') && logOut) {
item.style.display = 'none';
} else {
item.style.visibility = 'visible';
}
});
}
});
});
Save.
In this code
- Code:
const adminNick = 'Admin'; |
instead of Admin, specify your nickname ( in quotes) to have access to the guest sections.
Result:
View for admin
View for users:
View for guests:
P.S. script works with this hierarchy (AP - Display - Structure and hierarchy):