1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

medals put in signature

Discussion in 'XenForo Development Discussions' started by mmoore5553, Mar 11, 2012.

  1. mmoore5553

    mmoore5553 Well-Known Member

    Does anyone know how to do this. I changed the listener.php and put in the correct area but i do not see a hook I can have it be part of the signature. It would be above normal signature. I have done with with userfields but would love to do it with medal system.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There is a hook directly above the signature you can use:

    Code:
    		<xen:hook name="message_content" params="{xen:array 'message={$message}'}">
    		<div class="messageContent">		
    			<article>
    				<blockquote class="messageText ugc baseHtml{xen:if $message.isIgnored, ' ignored'}">
    					<xen:include template="ad_message_body" />
    					{xen:raw $message.messageHtml}
    				</blockquote>
    			</article>
    			
    			{xen:raw $messageContentAfterTemplate}
    		</div>
    		</xen:hook>
    		
    		
    		<xen:if is="{$visitor.content_show_signature} && {$message.signature}">
    			<div class="baseHtml signature ugc{xen:if $message.isIgnored, ' ignored'}"><aside>{xen:raw $message.signatureHtml}</aside></div>
    		</xen:if>
    		
    		{xen:raw $messageAfterTemplate}
    		
    		<div id="likes-{$messageId}"><xen:if is="{$message.likes}"><xen:include template="likes_summary" /></xen:if></div>
    	</div>
    
    Append your output to the bottom of the contents of the "message_content" template hook.
     
  3. mmoore5553

    mmoore5553 Well-Known Member

    odd it is not working when i add it. I will try to contact developer on it.
     
  4. mmoore5553

    mmoore5553 Well-Known Member

    Curious is anyone up to fixing the medals to show up before signature . This is a paid request as i can not get the formatting correct to display. If i use the hook above it does not show up at all. I am sure something with the parameters but if i just do the hook it still does not do it.
     
    CritiKiL likes this.
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Can you post your function for the template_hook event?
     
  6. mmoore5553

    mmoore5553 Well-Known Member

    I have tried two different ways ...

    One setting is manual and you have to put the code in where you want it. I added it at the very top in red. It was suppose to render where you put the manual code. Which did not work. Then i added a drop down but i have took it out but that code is in red at bottom. The color in orange i was not sure if i had to add anything there. This is the listener.php.
    PHP:
    <?php
    class bdMedal_Listener {
        public static function 
    load_class($class, array &$extend) {
            static 
    $classes = array(
          [
    COLOR=#ff9900]    'XenForo_ControllerAdmin_User',[/COLOR]
       
    [COLOR=#ff9900]            'XenForo_ControllerPublic_Member',[/COLOR]
    [COLOR=#ff9900]            'XenForo_ControllerPublic_Help',[/COLOR]
       
    [COLOR=#ff9900]            'XenForo_Model_Import',[/COLOR]
            
    );
       
            if (
    in_array($class$classes)) {
                
    $extend[] = str_replace('XenForo_''bdMedal_Extend_'$class);
            }
        }
     
        public static function 
    load_class_importer($class, array &$extend) {
            if (
    strpos($class'vBulletin') != false AND !defined('bdMedal_Extend_Importer_vBulletin_LOADED')) {
                
    $extend[] = 'bdMedal_Extend_Importer_vBulletin';
            }   
        }
     
        public static function 
    init_dependencies(XenForo_Dependencies_Abstract $dependencies, array $data) {
            
    XenForo_Template_Helper_Core::$helperCallbacks['medalimage'] = array('bdMedal_Model_Medal''helperMedalImage');
            
    XenForo_Template_Helper_Core::$helperCallbacks['medalimagesize'] = array('bdMedal_Model_Medal''helperMedalImageSize');
        }
     
        public static function 
    template_create($templateName, array &$paramsXenForo_Template_Abstract $template) {
      [
    COLOR=#ff0000]    if ($templateName == 'message') {[/COLOR]
    [COLOR=#ff0000]            $template->preloadTemplate('bdmedal_message_medals');[/COLOR]
            
    }
            elseif (
    $templateName == 'member_view') {
                
    $template->preloadTemplate('bdmedal_member_view_sidebar_middle1');
                
    $template->preloadTemplate('bdmedal_member_view_tabs_heading');
                
    $template->preloadTemplate('bdmedal_member_view_tabs_content');
            }
            elseif (
    $templateName == 'PAGE_CONTAINER') {
                
    $template->preloadTemplate('bdmedal_navigation_tabs_help');
            }
        }
     
        public static function 
    template_hook($hookName, &$contents, array $hookParamsXenForo_Template_Abstract $template) {
            
    $positionInPost XenForo_Application::get('options')->get('bdMedal_positionInPost');
       
            if (
    $positionInPost != 'manual') {
                if (
    strpos($positionInPost$hookName) === 0) {
                    
    // found the position
                    
    $hookParams['user']['xf_bdmedal_awarded_cached'] = @unserialize($hookParams['user']['xf_bdmedal_awarded_cached']);
                    
    $ourTemplate $template->create('bdmedal_message_medals'$hookParams);
                    
    $rendered $ourTemplate->render();
               
                    
    // output
                    
    $positionInternal trim(str_replace($hookName''$positionInPost), '_');
                    switch (
    $positionInternal) {
                        case 
    'top':
                            
    $contents $rendered $contents;
                            break;
                        case 
    'bottom':
                            
    $contents .= $rendered;
                            break;
                    }
                }
            }
       
            if (
    $hookName == 'member_view_sidebar_middle1') {
                
    $ourTemplate $template->create('bdmedal_member_view_sidebar_middle1'$template->getParams());
                
    $rendered $ourTemplate->render();
                
    $contents .= $rendered;
            }
            elseif (
    $hookName == 'member_view_tabs_heading') {
                
    $ourTemplate $template->create('bdmedal_member_view_tabs_heading'$template->getParams());
                
    $rendered $ourTemplate->render();
                
    $contents .= $rendered;
            }
            elseif (
    $hookName == 'member_view_tabs_content') {
                
    $ourTemplate $template->create('bdmedal_member_view_tabs_content'$template->getParams());
                
    $rendered $ourTemplate->render();
                
    $contents .= $rendered;
            }
            elseif (
    $hookName == 'navigation_tabs_help') {
                
    $ourTemplate $template->create('bdmedal_navigation_tabs_help');
                
    $rendered $ourTemplate->render();
                
    $contents .= $rendered;
            }
      [
    COLOR=#ff0000]    elseif ($hookName == 'message_content') {[/COLOR]
    [COLOR=#ff0000]            $ourTemplate = $template->create('bdmedal_message_medals');[/COLOR]
    [COLOR=#ff0000]            $rendered = $ourTemplate->render();[/COLOR]
    [COLOR=#ff0000]            $contents .= $rendered;[/COLOR]
            
    }
        }
    }
     
  7. mmoore5553

    mmoore5553 Well-Known Member

    Um why is that color not rendering out . I reported that bug awhile ago but i see you jake using it fine ? I guess look for the color parts ...
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    Use code=rich or the dedicated php tags.
     
    mmoore5553 likes this.
  9. ragtek

    ragtek Guest

    it's a little bit tricky because of the requiored medal data for the template, but got if finally;)

    That's a own add-on, so you don't need to change anything in the orignal bd medal files:)
    set the display option to "manual"
     

    Attached Files:

  10. xfrocks

    xfrocks Well-Known Member

    Another way to do this is select the manual position in the option page and add this in 'message' template (anywhere)

    Code:
     <xen:include template="bdmedal_message_medals">
                <xen:map from="$message" to="$user" />
            </xen:include>
     
    Coop1979 and (deleted member) like this.
  11. CritiKiL

    CritiKiL Active Member

    I thought I would give this a try and it works but when I click on the medals, it produces an error: 'The requested member could not be found'. Any ideas to fix this? Here's an area of where the medals are showing:
    http://sck-mobile.com/community/ind...ine412kid-to-clan-killas®-online-gaming.2026/
     
  12. ragtek

    ragtek Guest

    i can't see the medals;)

    also the postbit looks really strange for guests because you're hidding the data...
    foob.PNG

    BUT wouldn't you need to hide them here => http://sck-mobile.com/community/index.php?forums/welcome-yourselves.6/ too;)

    if not, i can see at least, who posted the 1. and last post;)
     
  13. CritiKiL

    CritiKiL Active Member

    Oops! You have to be signed in to view the forum. Sorry I forgot ;-)
     
  14. ragtek

    ragtek Guest

    have you tried it with http://xenforo.com/community/threads/medals-put-in-signature.29110/#post-340758 ???

    IMO it doesn't make sense to continue work on an unnecessary add-on, if it's already possible with the original add-on^^:d
     
  15. CritiKiL

    CritiKiL Active Member

  16. xfrocks

    xfrocks Well-Known Member

    It's a post link. Post #10 of this thread, I quoted below for your viewing:

    He asked if you tried this in the template instead of using his addon.
     
    CritiKiL and (deleted member) like this.
  17. CritiKiL

    CritiKiL Active Member

    Ok, I understand about putting the code into the 'message' template but the part about "selecting the manual position in the option page" has me confused...
     
  18. xfrocks

    xfrocks Well-Known Member

    In AdminCP > Options > [bd] Medal, you will find the position option. Set it to manual
     
  19. CritiKiL

    CritiKiL Active Member

    Oh, I see. But I actually wanted to keep them showing in the avatar area 'as well as' above the sigs...;-)
     
  20. xfrocks

    xfrocks Well-Known Member

    So you just need to add the code to the template. And keep the option as old value.
     
    1 person likes this.

Share This Page