Skip to content

Recent Cards plugin customization

Solved Customisation
21 3 6.7k 1
  • Although it is not used in this forum, I have a question about this plugin:

    https://github.com/NodeBB-Community/nodebb-plugin-recent-cards

    It basically creates a set of cards for each recent post.

    Screen Shot 2022-04-04 at 8.37.12 PM.png

    I wonder if there is an easy way to create a several px width border in each box(card) representing its own category color. Previously plugin was showing category-specific color as the background color; however, this is removed in the latest versions. I have got some tips from baris here: https://community.nodebb.org/topic/16249/recent-cards-does-not-slide-by-finger/8

    and I made some changes in the forked version here: https://github.com/YesilkartForum/nodebb-plugin-recent-cards-yesilkartforum/commit/844ab9ef890e5cb3e4d0a71e1a5f9b627c257ce8

    however, unfortunately, it did not work. Any help or tip is appreciated.

  • Although it is not used in this forum, I have a question about this plugin:

    https://github.com/NodeBB-Community/nodebb-plugin-recent-cards

    It basically creates a set of cards for each recent post.

    Screen Shot 2022-04-04 at 8.37.12 PM.png

    I wonder if there is an easy way to create a several px width border in each box(card) representing its own category color. Previously plugin was showing category-specific color as the background color; however, this is removed in the latest versions. I have got some tips from baris here: https://community.nodebb.org/topic/16249/recent-cards-does-not-slide-by-finger/8

    and I made some changes in the forked version here: https://github.com/YesilkartForum/nodebb-plugin-recent-cards-yesilkartforum/commit/844ab9ef890e5cb3e4d0a71e1a5f9b627c257ce8

    however, unfortunately, it did not work. Any help or tip is appreciated.

    @crazycells I have this running on https://hostrisk.com which is my cyber security (automated) news site. Are you looking for something like this ?

    46465831-6773-4784-8f23-feecc7db9117-image.png

    Hereโ€™s a jQuery function that will do this on the fly

    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('.recent-card-container').each(function(i) {
                var dataId = $(this).attr("data-cid");
                var color = $('[role="presentation"]', this).css("background-color");
                console.log("data-cid " + dataId + " is " + color);
                $('[data-cid="' + dataId + '"] .recent-card').attr("style", "border-color: " + color);
            });
        });
    });
    

    Paste this into your ACP -> Appearance -> Custom JS, save, and test

  • Although it is not used in this forum, I have a question about this plugin:

    https://github.com/NodeBB-Community/nodebb-plugin-recent-cards

    It basically creates a set of cards for each recent post.

    Screen Shot 2022-04-04 at 8.37.12 PM.png

    I wonder if there is an easy way to create a several px width border in each box(card) representing its own category color. Previously plugin was showing category-specific color as the background color; however, this is removed in the latest versions. I have got some tips from baris here: https://community.nodebb.org/topic/16249/recent-cards-does-not-slide-by-finger/8

    and I made some changes in the forked version here: https://github.com/YesilkartForum/nodebb-plugin-recent-cards-yesilkartforum/commit/844ab9ef890e5cb3e4d0a71e1a5f9b627c257ce8

    however, unfortunately, it did not work. Any help or tip is appreciated.

    @crazycells If I understand this correctly, you want a (for example, 5px) border around each card that is taken from the relevant categoryโ€™s colour ?

  • @crazycells If I understand this correctly, you want a (for example, 5px) border around each card that is taken from the relevant categoryโ€™s colour ?

    @phenomlab said in Recent Cards plugin customization:

    @crazycells If I understand this correctly, you want a (for example, 5px) border around each card that is taken from the relevant categoryโ€™s colour ?

    yes, actually even 1 px is doing the job. I made a change in inspector CSS codes to show the final result I aimโ€ฆ

    Screen Shot 2022-04-05 at 11.35.04 AM.png

  • Although it is not used in this forum, I have a question about this plugin:

    https://github.com/NodeBB-Community/nodebb-plugin-recent-cards

    It basically creates a set of cards for each recent post.

    Screen Shot 2022-04-04 at 8.37.12 PM.png

    I wonder if there is an easy way to create a several px width border in each box(card) representing its own category color. Previously plugin was showing category-specific color as the background color; however, this is removed in the latest versions. I have got some tips from baris here: https://community.nodebb.org/topic/16249/recent-cards-does-not-slide-by-finger/8

    and I made some changes in the forked version here: https://github.com/YesilkartForum/nodebb-plugin-recent-cards-yesilkartforum/commit/844ab9ef890e5cb3e4d0a71e1a5f9b627c257ce8

    however, unfortunately, it did not work. Any help or tip is appreciated.

    @crazycells I have this running on https://hostrisk.com which is my cyber security (automated) news site. Are you looking for something like this ?

    46465831-6773-4784-8f23-feecc7db9117-image.png

    Hereโ€™s a jQuery function that will do this on the fly

    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('.recent-card-container').each(function(i) {
                var dataId = $(this).attr("data-cid");
                var color = $('[role="presentation"]', this).css("background-color");
                console.log("data-cid " + dataId + " is " + color);
                $('[data-cid="' + dataId + '"] .recent-card').attr("style", "border-color: " + color);
            });
        });
    });
    

    Paste this into your ACP -> Appearance -> Custom JS, save, and test

  • @phenomlab said in Recent Cards plugin customization:

    @crazycells If I understand this correctly, you want a (for example, 5px) border around each card that is taken from the relevant categoryโ€™s colour ?

    yes, actually even 1 px is doing the job. I made a change in inspector CSS codes to show the final result I aimโ€ฆ

    Screen Shot 2022-04-05 at 11.35.04 AM.png

    up there I only changed this line:

    border: 1px solid #e3e3e3;
    
  • @crazycells I have this running on https://hostrisk.com which is my cyber security (automated) news site. Are you looking for something like this ?

    46465831-6773-4784-8f23-feecc7db9117-image.png

    Hereโ€™s a jQuery function that will do this on the fly

    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('.recent-card-container').each(function(i) {
                var dataId = $(this).attr("data-cid");
                var color = $('[role="presentation"]', this).css("background-color");
                console.log("data-cid " + dataId + " is " + color);
                $('[data-cid="' + dataId + '"] .recent-card').attr("style", "border-color: " + color);
            });
        });
    });
    

    Paste this into your ACP -> Appearance -> Custom JS, save, and test

    @phenomlab lol yes, that is exactly what I was looking for ๐Ÿ˜„
    it worked great!

    thank you very much ๐Ÿ˜„

    Screen Shot 2022-04-05 at 11.40.43 AM.png

  • phenomlabundefined phenomlab has marked this topic as solved on
  • @phenomlab lol yes, that is exactly what I was looking for ๐Ÿ˜„
    it worked great!

    thank you very much ๐Ÿ˜„

    Screen Shot 2022-04-05 at 11.40.43 AM.png

    @crazycells Happy to help. That function wasnโ€™t always there - I just finished writing it ๐Ÿ™‚

  • @crazycells Happy to help. That function wasnโ€™t always there - I just finished writing it ๐Ÿ™‚

    @phenomlab said in Recent Cards plugin customization:

    @crazycells Happy to help. That function wasnโ€™t always there - I just finished writing it ๐Ÿ™‚

    Thanks a lot ๐Ÿ™‚ ๐Ÿ™

  • @phenomlab said in Recent Cards plugin customization:

    @crazycells Happy to help. That function wasnโ€™t always there - I just finished writing it ๐Ÿ™‚

    Thanks a lot ๐Ÿ™‚ ๐Ÿ™

    @crazycells No problems. Feel free to comment out line

    console.log("data-cid " + dataId + " is " + color);
    

    From that function as itโ€™s only used to ensure the script is picking up the relevant background-color from the category.

  • @crazycells No problems. Feel free to comment out line

    console.log("data-cid " + dataId + " is " + color);
    

    From that function as itโ€™s only used to ensure the script is picking up the relevant background-color from the category.

    @phenomlab I think in dark mode, it is going back to normal. Is there an easy way to keep the same border color in dark mode as well?

  • @phenomlab I think in dark mode, it is going back to normal. Is there an easy way to keep the same border color in dark mode as well?

    @crazycells Dark mode shouldnโ€™t have any impact - can you provide a URL where I can see this ?

  • @crazycells Dark mode shouldnโ€™t have any impact - can you provide a URL where I can see this ?

    @phenomlab Yes, I see the issue. Itโ€™s because of lazy CSS classes meaning this below will override everything else when body.lights-out is appended to the existing CSS class.

    body.lights-out .recent-cards .recent-card-container .recent-card {
        background-color: #2E2E2E;
        border: #848484;
    }
    

    You should be able to work around that by adding this into your custom CSS

    body.lights-out .recent-cards .recent-card-container .recent-card {
        border: 1px solid #848484;
    }
    

    b1dbdcde-f723-4446-b3c8-3f4f4d6856fb-image.png

    Let me know how you get on.

  • @phenomlab Yes, I see the issue. Itโ€™s because of lazy CSS classes meaning this below will override everything else when body.lights-out is appended to the existing CSS class.

    body.lights-out .recent-cards .recent-card-container .recent-card {
        background-color: #2E2E2E;
        border: #848484;
    }
    

    You should be able to work around that by adding this into your custom CSS

    body.lights-out .recent-cards .recent-card-container .recent-card {
        border: 1px solid #848484;
    }
    

    b1dbdcde-f723-4446-b3c8-3f4f4d6856fb-image.png

    Let me know how you get on.

    @phenomlab Yes, I found the lines and fixed them ๐Ÿ˜„

    Thank you very much. Since the recent card plugin-related codes are not included in the night mode plugin; we have previously added some custom codes for recent cardsโ€ฆ Apparently, those codes were creating the problem. Now, it is fixed ๐Ÿ‘

  • phenomlabundefined phenomlab referenced this topic on
  • phenomlabundefined phenomlab referenced this topic on
  • hi @phenomlab , somehow recent cards are not clickable in my forum after using these codes, however, it works fine hereโ€ฆ

    Normally, when I click a card it takes me to that topic, however, nothing happens now.

    I use this CSS:

    
    li.col-md-3.col-sm-6.col-xs-12.recent-card-container {
        width: 290px !important;
    }
    

    this JS code:

    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('.recent-card-container').each(function(i) {
                var dataId = $(this).attr("data-cid");
                var color = $('[role="presentation"]', this).css("background-color");
                console.log("data-cid " + dataId + " is " + color);
                $('[data-cid="' + dataId + '"] .recent-card').attr("style", "border-color: " + color);
            });
        });
    });
    
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
       var categoryColor = $('[role="presentation"].icon').css("background-color");
                    $('li.topic-owner-post:nth-child(1)').css('border-color', categoryColor);
        });
    });
    
    
    window.addEventListener("load", () => {
        // CHROME
        if (navigator.userAgent.indexOf("Chrome") != -1) {
            console.log("Google Chrome");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: false
                });
            });
        } else {
            console.log("Others");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: true
                });
            });
        }
    });
    

    and this header:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script>
    
  • hi @phenomlab , somehow recent cards are not clickable in my forum after using these codes, however, it works fine hereโ€ฆ

    Normally, when I click a card it takes me to that topic, however, nothing happens now.

    I use this CSS:

    
    li.col-md-3.col-sm-6.col-xs-12.recent-card-container {
        width: 290px !important;
    }
    

    this JS code:

    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
            $('.recent-card-container').each(function(i) {
                var dataId = $(this).attr("data-cid");
                var color = $('[role="presentation"]', this).css("background-color");
                console.log("data-cid " + dataId + " is " + color);
                $('[data-cid="' + dataId + '"] .recent-card').attr("style", "border-color: " + color);
            });
        });
    });
    
    $(document).ready(function() {
        $(window).on('action:ajaxify.end', function(data) {
       var categoryColor = $('[role="presentation"].icon').css("background-color");
                    $('li.topic-owner-post:nth-child(1)').css('border-color', categoryColor);
        });
    });
    
    
    window.addEventListener("load", () => {
        // CHROME
        if (navigator.userAgent.indexOf("Chrome") != -1) {
            console.log("Google Chrome");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: false
                });
            });
        } else {
            console.log("Others");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: true
                });
            });
        }
    });
    

    and this header:

    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
    <script src="https://cdn.jsdelivr.net/bxslider/4.2.12/jquery.bxslider.min.js"></script>
    

    @crazycells Strange. Are there any errors appearing in the console at your end ? When I look at the console itself, I see

    0a1b4841-6da4-4809-958e-4636441ada61-image.png

    However, this doesnโ€™t seem to have any impact on the recent cards - the links appear to work fine. I think this may be a caching issue at your end ?

  • @crazycells Strange. Are there any errors appearing in the console at your end ? When I look at the console itself, I see

    0a1b4841-6da4-4809-958e-4636441ada61-image.png

    However, this doesnโ€™t seem to have any impact on the recent cards - the links appear to work fine. I think this may be a caching issue at your end ?

    @phenomlab hmm, I tried on different browsers with iPhone.

    First of all, when I delete this code:

    
    window.addEventListener("load", () => {
        // CHROME
        if (navigator.userAgent.indexOf("Chrome") != -1) {
            console.log("Google Chrome");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: false
                });
            });
        } else {
            console.log("Others");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: true
                });
            });
        }
    });
    

    then, everything is normal, cards are clickable but of course, sliding does not work.

    However, when I activate it, I could not click the cards on Safari, but it was working on Firefox. I can slide the cards on both browsers by the way.

    So, I guess like Google Chrome, Safari has its own problems with this sliding application?

  • I forgot to writeโ€ฆ I do not see any errors on the console.

  • @phenomlab hmm, I tried on different browsers with iPhone.

    First of all, when I delete this code:

    
    window.addEventListener("load", () => {
        // CHROME
        if (navigator.userAgent.indexOf("Chrome") != -1) {
            console.log("Google Chrome");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: false
                });
            });
        } else {
            console.log("Others");
            $(window).on('action:ajaxify.end', function(data) {
                $('.carousel-mode').bxSlider({
                    auto: false,
                    autoControls: true,
                    stopAutoOnClick: true,
                    pager: false,
                    keyboardEnabled: true,
                    touchEnabled: true
                });
            });
        }
    });
    

    then, everything is normal, cards are clickable but of course, sliding does not work.

    However, when I activate it, I could not click the cards on Safari, but it was working on Firefox. I can slide the cards on both browsers by the way.

    So, I guess like Google Chrome, Safari has its own problems with this sliding application?

    @crazycells odd. Should actually work on Safari. Can you change the line under โ€œOthersโ€ to be touchEnabled: false and see if that allows you to select the href links ?

    Obviously, save the code and reload the site before testing again.

  • @crazycells odd. Should actually work on Safari. Can you change the line under โ€œOthersโ€ to be touchEnabled: false and see if that allows you to select the href links ?

    Obviously, save the code and reload the site before testing again.

    @phenomlab said in Recent Cards plugin customization:

    @crazycells odd. Should actually work on Safari. Can you change the line under โ€œOthersโ€ to be touchEnabled: false and see if that allows you to select the href links ?

    Obviously, save the code and reload the site before testing again.

    with this change, in both Safari and Firefox browsers, I can click the cards and go to the topics, however sliding does not work.

  • @phenomlab said in Recent Cards plugin customization:

    @crazycells odd. Should actually work on Safari. Can you change the line under โ€œOthersโ€ to be touchEnabled: false and see if that allows you to select the href links ?

    Obviously, save the code and reload the site before testing again.

    with this change, in both Safari and Firefox browsers, I can click the cards and go to the topics, however sliding does not work.

    @crazycells yes, unsurprising as they both use the webkit CSS rendering engine. This will be the same bug I reference earlier that affects Google Chrome. Not much that can be done sadly.


Did this solution help you?
Did you find the suggested solution useful? Support ๐Ÿ’— Sudonix with a coffee โ˜•
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • NodeBB recent cards customisation

    Solved Customisation nodebb recent cards
    3
    1
    2 Votes
    3 Posts
    713 Views
    @phenomlab thank you very much for the assistance Mark, massively appreciated as always. The great thing about this is itโ€™s all documented for other NodeBB users that come looking for solutions . Looks far better .
  • Composer Zen icon?

    Solved Configure nodebb
    8
    1
    2 Votes
    8 Posts
    1k Views
    @DownPW exactly. Not really a new concept, and in all honesty, not something Iโ€™ve ever used. If you consider the need to add links and references, or citations, youโ€™d need to be able to see other parts of the screen!
  • Can you adjust Admin settings on your NodeBB?

    Bugs nodebb
    5
    0 Votes
    5 Posts
    1k Views
    @Panda as, yes, now I understand and that makes 100% sense. It means those who get down voted can still have an opinion and use common services. And yes, youโ€™re right. Rather than down vote, just ignore if you donโ€™t agree.
  • Forum Icons NodeBB

    Solved Customisation icons forum nodebb
    13
    0 Votes
    13 Posts
    2k Views
    @cagatay That matches what I see [image: 1667218162107-4f0f858d-9812-42b1-9f61-ffb13d31dccd-image.png]
  • Tenor GIF Plugin

    Solved Customisation plugin
    19
    1
    5 Votes
    19 Posts
    4k Views
    @phenomlab Also for me now Upgraded in ACP and all good . Thx.
  • 11 Votes
    23 Posts
    6k Views
    @DownPW No issues. Thanks to the Google Chrome โ€œbugโ€, it does have some restrictions, but works fine other than that. I have an odd issue where it doesnโ€™t work on Firefox mobile, but works fine on Firefox desktop.
  • [NODEBB] Help for my custom CSS

    Solved Customisation nodebb css bugfix
    237
    49 Votes
    237 Posts
    80k Views
    @baris said: You should change your selectors so it doesnโ€™t look at the entire document. You probably only want to apply fancybox to stuff inside the #content element which is what changes when the user navigates around the page. So use $('#content a').... for your selectors then the forum logo in the header wonโ€™t be selected. I modified the JS Fancybox code now and this code and it seem better // --------------------------------------------- // Fancybox Media Reader (Without Website Logo) // --------------------------------------------- if (top.location.pathname !== '/login') { $(window).on('action:posts.loaded', function(data) { console.log("Polling DOM for lazyLoaded images to apply Fancybox"); $(document).ready(function() { $('#content a').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); }); }); }); } if (top.location.pathname !== '/login') { $(document).ready(function() { $(window).on('action:ajaxify.end', function(data) { $('#content a').not('.logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); data.preventDefault() // Strip out the images contained inside blockquotes as this looks nasty :) $('#content blockquote img').remove(); }); Fancybox.bind( '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]', { groupAll: true, } ); }); }); } // Chat fancybox - fires when chat module loaded and AJAX calls new chat $(document).ready(function() { $(window).on('action:chat.loaded', function(data) { // >>> Se limiter au contenu principal uniquement <<< $('#content img').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { var newHref = $(this).attr("src"); $(this).wrap("<a class='fancybox' href='" + newHref + "'/>"); $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); data.preventDefault(); // Strip out the images contained inside blockquotes as this looks nasty :) $('#content blockquote img').remove(); }); Fancybox.bind( '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]', { groupAll: true, } ); }); }); For the logo, I must use overflow: visible !important; on [component="brand/logo"] /* --- Logo --- */ [component="brand/logo"] { max-height: 50px; width: auto; height: auto; max-width: 100%; display: block; object-fit: contain; object-position: left center; overflow: visible !important; } Better result !!
  • [NodeBB] First post customization

    Solved Customisation nodebb
    5
    4 Votes
    5 Posts
    1k Views
    @phenomlab thanks