Skip to content

Post Style View

Solved Customisation
  • @phenomlab maybe it depends on me or my web browser. thank you 🙂

  • @cagatay No problems. I checked this in an incognito session also, with no issues

    748735c8-4141-4185-9d46-4eb3f8023744-image.png

  • @cagatay said in Post Style View:

    maybe it depends on me or my web browser. thank you

    One thing I have noticed is that there are a number of errors on your site in the console. My concern here is that the jQuery functions I added are not being executed. For example, I removed the below function from your site about 30 minutes ago because it’s malformed

    });ment).ready(function () {
        function animateTags() {
        	if (ajaxify.data.template.name === 'categories') {
        		var tags = $('.popular-tags .tag-item');
        		var bar = $('<div class="popular-tags-bar"></div>');
        		tags.append(bar);
        		
        		var max;
        		
        		setTimeout(function() {
            		tags.each(function() {
            		   var bar = $(this).find('.popular-tags-bar');
            		   var val = parseInt(bar.parents('a').find('.tag-topic-count').text(), 10);
            		   max = max > val ? max : val;
            		   
            		   bar.css({
            		       width: val / max * 100 + '%'
            		   });
            		});
        		}, 100)
        	}
        }
        animateTags();
        $(window).on('action:ajaxify.end', animateTags);
    });
    

    As you can see, this isn’t right at all. It should be

    $(document).ready(function () {
        function animateTags() {
            if (ajaxify.data.template.name === 'categories') {
                var tags = $('.popular-tags .tag-item');
                var bar = $('<div class="popular-tags-bar"></div>');
                tags.append(bar);
    
                var max;
    
                setTimeout(function () {
                    tags.each(function () {
                        var bar = $(this).find('.popular-tags-bar');
                        var val = parseInt(bar.parents('a').find('.tag-topic-count').text(), 10);
                        max = max > val ? max : val;
    
                        bar.css({
                            width: val / max * 100 + '%'
                        });
                    });
                }, 100);
            }
        }
        animateTags();
        $(window).on('action:ajaxify.end', animateTags);
    });
    

    I’ve put this back how it should be, but am curious as to where that came from.

  • @phenomlab i can not understand how it can be, i do not touch anything js side.

    so now everything is working and code is okey hope so?

  • @cagatay Not entirely. There is an ajax call I need to use called action:ajaxify.loaded but this does not seem to be firing on your site. It’s opposite, action:ajaxify.end works fine (as you’ll see if you press F5) but the former does not, and I can’t see any reason as to why.

  • @phenomlab maybe it depends on my nodebb version or really i can not say anything coz i don not know what is the ajax code as well 🙂

  • @cagatay Your NodeBB is up to date, so not an issue there. Just seems odd that no matter what I try, it doesn’t trigger. Investigating

  • @phenomlab maybe there is a problem in my vps or ubuntu is not clearlu working or library etc…

  • @cagatay Not sure, but will check out a theory I have first before we go down that route.

  • @cagatay Found the issue. It appears that the hook I should be calling is in fact action:posts.loaded and not action:ajaxify.loaded 🤦

    Should be fixed now but take a look. The best way to test this is to find a topic with lots of posts, and scroll to the bottom. Then, reload the page, and start scrolling up from the bottom to the top. As the new posts are added into the DOM, that function I wrote should execute and add the missing class

    For anyone else following this thread, the two required jQuery functions are

        $(window).on('action:posts.loaded', function(data) {
            $(document).ready(function() {
            if ($('li[component="post"]').hasClass("")) {
                console.log("New posts detected,so adding classes for messenger type view");
                $('li[component="post"]').addClass('topic-response-post');
            }
        });
    });
        $(window).on('action:ajaxify.end', function(data) {
            $(document).ready(function() {
            if ($('li[component="post"]').hasClass("")) {
                console.log("Adding required classes for messenger type view");
                $('li[component="post"]').addClass('topic-response-post');
            }
        });
    });
    
  • @phenomlab i checked topic with a lots of posts 3 times 🙂 everything is clear and very well now. thank you your effort.

  • @cagatay No problems. Glad it’s all working. I need to document this for others to be able to use.

  • @phenomlab said in Post Style View:

    @cagatay No problems. Glad it’s all working. I need to document this for others to be able to use.

    this post is very good document for the users who will want to use it 🙂

  • @cagatay Yes, but I want to create something more concise and simpler to follow

  • phenomlabundefined phenomlab has marked this topic as solved on
  • @cagatay in case you’re still following this thread, I found a far more efficient way of adding the classes using jQuery. To this end, you can change this block above with this code

    // Target those elements already loaded in the DOM
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    // Target elements dynamically added to the DOM on post load
    $(document).ready(function() {
        $(window).on('action:ajaxify.loaded', function(data) {
            $('li[component="post"]').each(function(i, obj) {
                if (!$(this).hasClass('self-post') || (!$(this).hasClass('self-post'))) {
                    console.log("Adding required classes for messenger type view");
                    $(this).addClass('topic-response-post');
                }
    
            });
        });
    });
    
  • @phenomlab said in Post Style View:

    // Target those elements already loaded in the DOM
    $(document).ready(function() {
    $(window).on(‘action:ajaxify.end’, function(data) {
    $(‘li[component=“post”]’).each(function(i, obj) {
    if (!$(this).hasClass(‘self-post’) || (!$(this).hasClass(‘self-post’))) {
    console.log(“Adding required classes for messenger type view”);
    $(this).addClass(‘topic-response-post’);
    }

        });
    });
    

    });
    // Target elements dynamically added to the DOM on post load
    $(document).ready(function() {
    $(window).on(‘action:ajaxify.loaded’, function(data) {
    $(‘li[component=“post”]’).each(function(i, obj) {
    if (!$(this).hasClass(‘self-post’) || (!$(this).hasClass(‘self-post’))) {
    console.log(“Adding required classes for messenger type view”);
    $(this).addClass(‘topic-response-post’);
    }

        });
    });
    

    });

    thank you Mark.
    changed it.

  • @phenomlab there is small problem after revised codes which you shared.
    problem is shown below; answered nick and labels nested.

    8cb60812-c40c-4834-bdb2-bd8ef6271340-image.png

  • @cagatay that’s just a margin missing. The code I provided won’t be causing that. If you look for the element in the developers console and add a margin-left value to it, that should resolve it.

  • @phenomlab may i use this code?

    .topic-owner-post [itemprop="author"] {
        float: left;
    }
    // Add these to (or edit) the existing classes you have
    .user-level-topic {
        float: none;
    }
    .group-label {
        margin-top: -1px;
    }
    .topic-owner-post [itemprop="author"]:after {
        margin-top: 1px;
        height: 18px;
    }
    
  • @cagatay from the screenshot you provided, it looks like you’ve used them. They are fine to use, but you are missing a couple of styles.

    I’ll have a look at this tomorrow and give you the remainder of the code you need.


Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation 💗

  • Nodebb icon on google page

    Solved Customisation
    9
    4 Votes
    9 Posts
    597 Views

    @Panda It’s been raised multiple times, but only for the open source version, and not hosted.

  • Nodebb design

    Solved General
    2
    1 Votes
    2 Posts
    146 Views

    @Panda said in Nodebb design:

    One negative is not being so good for SEO as more Server side rendered forums, if web crawlers dont run the JS to read the forum.

    From recollection, Google and Bing have the capability to read and process JS, although it’s not in the same manner as a physical person will consume content on a page. It will be seen as plain text, but will be indexed. However, it’s important to note that Yandex and Baidu will not render JS, although seeing as Google has a 90% share of the content available on the web in terms of indexing, this isn’t something you’ll likely lose sleep over.

    @Panda said in Nodebb design:

    The “write api” is preferred for server-to-server interactions.

    This is mostly based around overall security - you won’t typically want a client machine changing database elements or altering data. This is why you have “client-side” which could be DOM manipulation etc, and “server-side” which performs more complex operations as it can communicate directly with the database whereas the client cannot (and if it can, then you have a serious security flaw). Reading from the API is perfectly acceptable on the client-side, but not being able to write.

    A paradigm here would be something like SNMP. This protocol exists as a UDP (UDP is very efficient, as it is “fire and forget” and does not wait for a response like TCP does) based service which reads performance data from a remote source, thus enabling an application to parse that data for use in a monitoring application. In all cases, SNMP access should be “RO” (Read Only) and not RW (Read Write). It is completely feasible to assume complete control over a firewall for example by having RW access to SNMP and then exposing it to the entire internet with a weak passphrase.

    You wouldn’t do it (at least, I hope you wouldn’t) and the same ethic applies to server-side rendering and the execution of commands.

  • 1 Votes
    1 Posts
    278 Views
    No one has replied
  • nodebb loading emojis

    Solved Configure
    16
    1 Votes
    16 Posts
    464 Views

    @DownPW sure. Let me have a look at this in more detail. I know nginx plus has extensive support for this, but it’s not impossible to get somewhere near acceptable with the standard version.

    You might be better off handling this at the Cloudflare level given that it sits in between the requesting client and your server.

  • NodeBB Theme/Skin Switcher

    Solved Customisation
    38
    7 Votes
    38 Posts
    2k Views

    @Teemberland great spot ! You should create a PR for that so they can include it in the official repository.

    Just be aware that any subsequent releases will overwrite your fix without the PR.

  • 38 Votes
    193 Posts
    29k Views

    OMG make sense

    Thanks dude 🙂

  • 4 Votes
    5 Posts
    642 Views

    @phenomlab thanks 🙏

  • 0 Votes
    3 Posts
    683 Views

    @phenomlab many thanks Mark 😁.