The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
4 posters

    Replace avatar with topic image to recent topic widget

    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Replace avatar with topic image to recent topic widget

    Post by TheCrow October 22nd 2014, 1:20 am

    Hello,

    I want the avatar on my recent topic widget to be replaced by the image of the specific post.
    If it is possible, my forum is PunBB and this is my Forum Link!

    I use for the recent topic widget this template:
    Code:
    <!-- BEGIN scrolling_row -->
    <div class="module main1">
      <div class="main-head1"><div class="h3">Πρόσφατα Θέματα</div></div>
      <div class="main-content" id="comments_scroll_div">
          <!-- BEGIN recent_topic_row -->
              <div class="avt_recent">
                  <div class="recent_space">
          <a onmouseover="document.getElementById('comments_scroll_container').stop();" onmouseout="document.getElementById('comments_scroll_container').start();" href="{scrolling_row.recent_topic_row.U_TITLE}" title="{scrolling_row.recent_topic_row.L_TITLE}">{scrolling_row.recent_topic_row.L_TOPIC_TITLE}</a><br />
              <img src="{ICON_TIME}" alt="" />{scrolling_row.recent_topic_row.S_POSTTIME} {BY}
        <!-- BEGIN switch_poster -->
          <a onmouseover="document.getElementById('comments_scroll_container').stop();" onmouseout="document.getElementById('comments_scroll_container').start();" href="{scrolling_row.recent_topic_row.switch_poster.U_POSTER}">{scrolling_row.recent_topic_row.switch_poster.S_POSTER}</a><br /><br />
          <!-- END switch_poster -->
          <!-- BEGIN switch_poster_guest -->
          {scrolling_row.recent_topic_row.switch_poster_guest.S_POSTER}<br /><br />
          <!-- END switch_poster_guest -->
          <!--
          <a onmouseover="document.getElementById('comments_scroll_container').stop();" onmouseout="document.getElementById('comments_scroll_container').start();" href="{scrolling_row.recent_topic_row.U_POSTER}">{scrolling_row.recent_topic_row.S_POSTER}</a><br /><br />
          -->
                </div>
              </div>
          <!-- END recent_topic_row -->
      </div>
    </div>
    <script type="text/javascript">
    //<![CDATA[
    $(function(){
      div_marquee('comments_scroll_div', 'comments_scroll_container', '{SCROLL_WAY}', '{SCROLL_STEP}', '{SCROLL_DELAY}', '{SCROLL_HEIGHT}');
    });
    //]]>
    </script>
    <!-- END scrolling_row -->
    <!-- BEGIN classical_row -->
    <div class="module main">
      <div class="main-head1"><h3>Πρόσφατα Θέματα</h3></div>
      <div class="main-content">
          <!-- BEGIN recent_topic_row -->
              <div class="avt_recent">
                  <div class="recent_space">
                    <a href="{classical_row.recent_topic_row.U_TITLE}" class="bottooom"><font style="font-size: 11px;">{classical_row.recent_topic_row.L_TITLE}</font></a><br />
          <!-- BEGIN switch_poster -->
                    <a href="{classical_row.recent_topic_row.switch_poster.U_POSTER}"><font style="font-size: 11px;">{classical_row.recent_topic_row.switch_poster.S_POSTER}</font></a>
          <!-- END switch_poster -->
          <!-- BEGIN switch_poster_guest -->
          {classical_row.recent_topic_row.switch_poster_guest.S_POSTER}
          <!-- END switch_poster_guest -->
                    {ON} <font style="font-size: 11px;" class="bottooom">- {classical_row.recent_topic_row.S_POSTTIME}</font><br /><br />
          <!--
          <a href="{classical_row.recent_topic_row.U_POSTER}">{classical_row.recent_topic_row.S_POSTER}</a> {ON} {classical_row.recent_topic_row.S_POSTTIME}<br /><br />
            -->
                </div>
              </div><br/>
        <!-- END recent_topic_row -->
      </div>
    </div>
    <!-- END classical_row -->

    Thanks in advance,
    MrMind
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by _Twisted_Mods_ October 22nd 2014, 1:36 am

    .avt_recent img{background-image: url(linktoimage)}
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by Van-Helsing October 22nd 2014, 2:20 am

    Hello Mr.Mind,
    Try to use this variable
    Code:
    <img src="{post_row.switch_attachments.switch_post_attachments.U_IMG}" />

    instead of avatar variable in your code or if its not working try to add the hanckidesc variable.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by TheCrow October 22nd 2014, 12:10 pm

    To make the avatars display on the widget i am currently using this javascript:
    Code:
    $(function(){
       
          if(!window.localStorage) return;
       
          // Avatar por defecto
            var default_avatar= 'http://2img.net/i/fa/invision/pp-blank-thumb.png';
       
          // Tiempo de cache, aqui 24 h * 60 m * 60 s * 1000 ms entonces un día
            var caching_time= 24*60*60*1000;
       
          // Tiempo de cache de un error, ici 60 s * 1000 ms entonces un minuto
            var caching_error= 60*1000;
       
          var set_avatar= function(id) {
                $('.mini_ava2.member'+id).html('<img src="'+get_avatar(id)+'" />');
            };
       
          var get_avatar= function(id) {
                if(localStorage.getItem('t_ava'+id) < +new Date - caching_time || (localStorage.getItem('d_ava'+id)==default_avatar && localStorage.getItem('t_ava'+id) < +new Date - caching_error))
                {
                    localStorage.setItem('d_ava'+id, default_avatar);
                    $.get('/u'+id, function (d){
                        localStorage.setItem('t_ava'+id,+new Date);
                        localStorage.setItem('d_ava'+id, $('#profile-advanced-right .module:first div img:first,.forumline td.row1.gensmall:first > img, .frm-set.profile-view.left dd img,dl.left-box.details:first dd img, .row1 b .gen:first img, .real_avatar img',d).first().attr('src')||default_avatar);
                        set_avatar(id);
                    });
                }
                return localStorage.getItem('d_ava'+id);
            };
       
          var to_replace= {};
       
        $('.module.main:has(a[href^="/t"]) a[href^="/u"]').each(function(){
                to_replace[$(this).attr('href').substr(2)]= 1;
                $(this).before('<span class="mini_ava2 member'+$(this).attr('href').substr(2)+'"></span>');
            });
       
          for(i in to_replace)
            {
                set_avatar(i);
            };
       
      });

    I need the avatars to go and them to be replaced by' as far as i'm concerned a different javascript which will grab the description of the post in the recent topic widget.



    Replace avatar with topic image to recent topic widget Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Van-Helsing
    Van-Helsing
    Hyperactive


    Male Posts : 2431
    Reputation : 116
    Language : English, Greek

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by Van-Helsing October 22nd 2014, 12:19 pm

    Hello Mr. Mind,
    Do you have the hancki's code and/ or js which you have for image preview in topics_list box?
    We need it to adapt the widget code.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by TheCrow October 23rd 2014, 1:20 am

    java:

    CSS:

    posting_body (template):



    Replace avatar with topic image to recent topic widget Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by TheCrow October 24th 2014, 2:31 pm

    Bump!



    Replace avatar with topic image to recent topic widget Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by TheCrow October 25th 2014, 3:48 pm

    Bump again!



    Replace avatar with topic image to recent topic widget Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by Ange Tuteur October 25th 2014, 4:38 pm

    Hello MrMind,

    Replace your mod_recent_topics template by :
    Code:
    <!-- BEGIN scrolling_row -->
    <div id="recentTopics" class="module main1">
     Â <div class="main-head1"><div class="h3">Πρόσφατα Θέματα</div></div>
     Â <div class="main-content" id="comments_scroll_div">
     Â     <!-- BEGIN recent_topic_row -->
     Â         <div class="avt_recent">
     Â             <div class="recent_space">
     Â     <a onmouseover="document.getElementById('comments_scroll_container').stop();" onmouseout="document.getElementById('comments_scroll_container').start();" href="{scrolling_row.recent_topic_row.U_TITLE}" title="{scrolling_row.recent_topic_row.L_TITLE}">{scrolling_row.recent_topic_row.L_TOPIC_TITLE}</a><br />
     Â         <img src="{ICON_TIME}" alt="" />{scrolling_row.recent_topic_row.S_POSTTIME} {BY}
     Â   <!-- BEGIN switch_poster -->
     Â     <a onmouseover="document.getElementById('comments_scroll_container').stop();" onmouseout="document.getElementById('comments_scroll_container').start();" href="{scrolling_row.recent_topic_row.switch_poster.U_POSTER}">{scrolling_row.recent_topic_row.switch_poster.S_POSTER}</a><br /><br />
     Â     <!-- END switch_poster -->
     Â     <!-- BEGIN switch_poster_guest -->
     Â     {scrolling_row.recent_topic_row.switch_poster_guest.S_POSTER}<br /><br />
     Â     <!-- END switch_poster_guest -->
     Â     <!--
     Â     <a onmouseover="document.getElementById('comments_scroll_container').stop();" onmouseout="document.getElementById('comments_scroll_container').start();" href="{scrolling_row.recent_topic_row.U_POSTER}">{scrolling_row.recent_topic_row.S_POSTER}</a><br /><br />
     Â     -->
     Â           </div>
     Â         </div>
     Â     <!-- END recent_topic_row -->
     Â </div>
    </div>
    <script type="text/javascript">
    //<![CDATA[
    $(function(){
     Â div_marquee('comments_scroll_div', 'comments_scroll_container', '{SCROLL_WAY}', '{SCROLL_STEP}', '{SCROLL_DELAY}', '{SCROLL_HEIGHT}');
    });
    //]]>
    </script>
    <!-- END scrolling_row -->
    <!-- BEGIN classical_row -->
    <div id="recentTopics" class="module main1">
     Â <div class="main-head1"><h3>Πρόσφατα Θέματα</h3></div>
     Â <div class="main-content">
     Â     <!-- BEGIN recent_topic_row -->
     Â         <div class="avt_recent">
     Â             <div class="recent_space">
     Â               <a href="{classical_row.recent_topic_row.U_TITLE}" class="bottooom"><font style="font-size: 11px;">{classical_row.recent_topic_row.L_TITLE}</font></a><br />
     Â     <!-- BEGIN switch_poster -->
     Â               <a href="{classical_row.recent_topic_row.switch_poster.U_POSTER}"><font style="font-size: 11px;">{classical_row.recent_topic_row.switch_poster.S_POSTER}</font></a>
     Â     <!-- END switch_poster -->
     Â     <!-- BEGIN switch_poster_guest -->
     Â     {classical_row.recent_topic_row.switch_poster_guest.S_POSTER}
     Â     <!-- END switch_poster_guest -->
     Â               {ON} <font style="font-size: 11px;" class="bottooom">- {classical_row.recent_topic_row.S_POSTTIME}</font><br /><br />
     Â     <!--
     Â     <a href="{classical_row.recent_topic_row.U_POSTER}">{classical_row.recent_topic_row.S_POSTER}</a> {ON} {classical_row.recent_topic_row.S_POSTTIME}<br /><br />
     Â       -->
     Â           </div>
     Â         </div><br/>
     Â   <!-- END recent_topic_row -->
     Â </div>
    </div>
    <!-- END classical_row -->


    Add this to your CSS :
    Display > Colors > CSS
    Code:
    .prevImg {
     Â background:url(http://2img.net/i/fa/prosilver_grey/subforum_read.gif) no-repeat;
     Â background-size:100% 100%;
     Â display:block;
     Â width:25px;
     Â height:25px;
     Â margin:3px;
     Â float:left;
     Â overflow:hidden;
    }

    .prevImg img {
     Â width:25px;
     Â height:25px;
    }


    and create a new script :
    Modules > JavaScript codes management > Create a new script

    Title : Your choice
    Placement : In all the pages
    Code:
    $(function() {
     Â var cacheTime = 1*60*1000; // mm * ss * ms

     Â if (!document.getElementById('recentTopics')) return;
     Â if (localStorage.recentExp > +new Date - cacheTime) return $('#recentTopics').html(localStorage.recentHTML);
     Â $('#recentTopics a.bottooom').each(function() {
     Â   $(this).before('<span class="prevImg"></span>');
     Â   $(this).prev().load($(this).attr('href') + ' .post:first .entry-content img:first', function() {
     Â     setTimeout(function() {
     Â       if (window.localStorage) {
     Â         localStorage.recentHTML = $('#recentTopics').html();
     Â         localStorage.recentExp = +new Date;
     Â       }
     Â     },1000);
     Â   });
     Â });
    });

    If there is a large amount of recent topics the data needs to be cached to prevent you from exceeding the request limit. At the top of the script you can adjust the cache time.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by TheCrow October 26th 2014, 1:41 pm

    How does the cashe works? If i leave it to 1 what does it do?



    Replace avatar with topic image to recent topic widget Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by Ange Tuteur October 26th 2014, 9:12 pm

    It will cache the topics and loaded images for 1m60s.
    TheCrow
    TheCrow
    Manager
    Manager


    Male Posts : 6916
    Reputation : 795
    Language : Greek, English

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by TheCrow October 27th 2014, 1:50 am

    Solved thanks!



    Replace avatar with topic image to recent topic widget Thecro10
     Forum of the Forums

    Forumotion Rules | Tips & Tricks |
    FAQ | Did you forget your password?



    *** The Support Forum will never ask you for your email or password, so please do not post them anywhere! ***
    No support via PM!
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: Replace avatar with topic image to recent topic widget

    Post by Ange Tuteur October 27th 2014, 4:17 am

    You're welcome ^^

    Topic archived

      Current date/time is September 22nd 2024, 8:35 pm