Help

Help > Forum > Argomenti e Post > Mostrare un numero di post accanto a ciascun post

Mostrare un numero di post accanto a ciascun post

Puoi utilizzare i passaggi seguenti per mostrare un numero di post accanto a ogni post in un argomento.

In genere è meglio utilizzare il link di risposta all'interno di un post quando si desidera fare riferimento a quel post nella risposta. Ciò include automaticamente un collegamento al post originale in modo che i lettori possano accedervi facilmente. Questo approccio è più affidabile rispetto alla menzione di un numero di post, poiché i numeri dei post possono cambiare se alcuni post vengono rimossi in seguito. Puoi anche utilizzare l'icona di condivisione in ogni post per copiare un link diretto ad esso.

  1. Accedi al tuo account Website Toolbox.
  2. Fai clic su Integra link nel menu principale.
  3. Fai clic su HTML collegamento.
  4. Copia il codice HTML qui sotto nel Codice HTML del tag principale del forum casella di testo:

    <!-- Add post numbers next to each post of a topic. ie: #1, #2, #3 -->
    <script>
    window.addEventListener("DOMContentLoaded", function () {
    	const container = document.querySelector('#posts-list');
    	if (!container || !window.location.href.match(/\/post\//)) return;
    	const observer = new MutationObserver(function (mutations) {
    		let shouldRenumber = false;
    		for (const m of mutations) {            
    			for (const node of m.addedNodes) {
    				if (node.nodeType !== 1) continue;
    				if (node.matches && node.matches('.post-body.pull-left')) shouldRenumber = true;
    				else if (node.querySelector && node.querySelector('.post-body.pull-left')) shouldRenumber = true;                
    				if (node.id && node.id.startsWith('post_row_')) {
    					const el = document.getElementById(node.id);
    					if (el && window.getComputedStyle(el).display === 'none') shouldRenumber = true;
    				}
    			}           
    			if (m.type === 'attributes' && m.target.id && m.target.id.startsWith('post_row_')) {
    				const el = m.target;
    				if (el && window.getComputedStyle(el).display === 'none') shouldRenumber = true;
    			}
    		}
    		if (shouldRenumber) renumberPosts();
    	});
        function renumberPosts() {
    		observer.disconnect();
    		let start = 1;
    		const pageText = jQ('.page-numbers').text() || '';
    		var paginationNum = pageText.replace(/,/g, ""); 
    		const matches = paginationNum.match(/[0-9]+/);        
    		if (matches) start = parseInt(matches[0], 10);
    		let postNumber = start;
    		if(start > 1) {
    			postNumber = start - 1;
    		}
    		jQ('#posts-list .post-body .post-options').each(function () {
    			const optionsElement = jQ(this);
    			if (optionsElement.closest('.post-body').is(':visible')) {
    				optionsElement.find('.post-number').remove();
    				if(optionsElement.closest('.first-post').length) {
    					optionsElement.append('#1');
    				} else {
    					optionsElement.append('#' + postNumber + '');                
    				}
    				postNumber++;
    			}
    		});
    		observer.observe(container, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });
        }    
        renumberPosts();
        observer.observe(container, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });
    });
    </script>
    
  5. Salva le modifiche.


If you still need help, please contact us.