by Razor12345 Wed Oct 25, 2023 8:14 am
Good afternoon!
Since you have heavily modified templates, I can't test the code on my test forum and use developer tools.
1) You need to create a field that will be displayed in the user's profile (
AP - Users & Groups - Profiles)
For the demonstration, I will use your existing field - Multikonta.
2) You need to change the
viewtopic_body template
Find the code fragment that is responsible for displaying the block with the class
.
In this block, add the following code:
- Code:
<div class="special__element"></div>
3)
AP - Modules - Javascript codes management - Create new JavaScriptTitle: any
Placement: In the topics
Code: - Code:
$(document).ready(function() {
const listOfPosts = document.querySelectorAll('.post');
listOfPosts.forEach((item) => {
const campoPElements = item.querySelectorAll('.pto-dentro .campo-p');
const lastCampoElements = campoPElements[campoPElements.length - 1];
const layoutSpecialElement = item.querySelector('.special__element');
if (lastCampoElements && layoutSpecialElement) {
const spesialElementTitle = lastCampoElements.querySelector('.campp-label').textContent;
if (spesialElementTitle === 'Multikonta : ') {
const specialElement = lastCampoElements.querySelector('.campp-cont').innerHTML;
layoutSpecialElement.append(specialElement);
lastCampoElements.style.display = 'none';
}
}
});
});
Save. Result:
Before:
After:
Important!
1) The profile field, which will be outside the information block, should be the last field in the users' profile.
2) This line of code checks for the presence of the field in the profile
- Code:
if (spesialElementTitle === 'Multikonta : ') { |
The string in quotes must match the name of the field in the profile.