Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

User Photo Link Instead of Text on Mobile Theme

vrijvlindervrijvlinder Papillon-Sauvage MVP
edited August 2013 in Tutorials

If you want to add the user image instead of text on the menu of the mobile this is what you can do . I added here a couple image links. The Home link which you can change to your home link, and the user image profile link.

Go to your themes folder find mobile, open the class.mobilethemehooks.php

I am including the entire file here use what you want or all of it

<?php if (!defined('APPLICATION')) exit();
/*
Copyright 2008, 2009 Vanilla Forums Inc.
This file is part of Garden.
Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Garden.  If not, see <http://www.gnu.org/licenses/>.
Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com
*/

class MobileThemeHooks implements Gdn_IPlugin {
   
   public function Setup() {
      return TRUE;
   }

   public function OnDisable() {
      return TRUE;
   }
   
   /**
    * Remove plugins that are not mobile friendly!
    */
   public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender) {
      // Remove plugins so they don't mess up layout or functionality.
      if (in_array($Sender->Application(), array('vanilla', 'conversations')) || ($Sender->Application() == 'dashboard' && in_array($Sender->Controller(), array('Activity', 'Profile', 'Search')))) {
         Gdn::PluginManager()->RemoveMobileUnfriendlyPlugins();
      }
   }
   
   /**
    * Add mobile meta info. Add script to hide iphone browser bar on pageload.
    */
   public function Base_Render_Before($Sender) {
      if (IsMobile() && is_object($Sender->Head)) {
         $Sender->Head->AddTag('meta', array('name' => 'viewport', 'content' => "width=device-width,minimum-scale=1.0,maximum-scale=1.0"));
         $Sender->Head->AddTag('meta', array('name' => 'apple-mobile-web-app-status-bar-style', 'content' => 'black-translucent'));
         $Sender->Head->AddTag('meta', array('name' => 'apple-mobile-web-app-capable', 'content' => 'yes'));
         
         $Sender->Head->AddString('
// If not looking for a specific comment, hide the address bar in iphone
var hash = window.location.href.split("#")[1];
if (typeof(hash) == "undefined") {
   setTimeout(function () {
     window.scrollTo(0, 1);
   }, 1000);
}
');
      }
   }
   
   /**
    * Add new discussion & conversation buttons to various pages.
    */
   public function CategoriesController_Render_Before($Sender) {
      $this->_AddButton($Sender, 'Discussion');
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender, 'ProfileLink');
   }
   
   public function Plugin_MobileHome_Controller_Render_Before($Sender) {
      $this->_AddButton($Sender, 'MobileHome');
   }
   
   public function DiscussionsController_Render_Before($Sender) {
      // Make sure that discussion clicks (anywhere in a discussion row) take the user to the discussion.
      if (property_exists($Sender, 'Head') && is_object($Sender->Head)) {
         $Sender->Head->AddString('
jQuery(document).ready(function($) {
   $("ul.DataList li.Item").click(function() {
      document.location = $(this).find("a.Title").attr("href");
   });
});
');
      }
      // Add the new discussion button to the page.
      
      $this->_AddButton($Sender, 'Discussion');
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender,'Categories');
       $this->_AddButton($Sender, 'ProfileLink');
 

   }

    
   public function DiscussionController_Render_Before($Sender) {
      $this->_AddButton($Sender, 'Discussion');
      $this->_AddButton($Sender,'Categories');
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender, 'ProfileLink');
   }

   public function ProfileController_Render_Before($Sender) {
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender, 'Discussion');
      $this->_AddButton($Sender,'Categories');
      $this->_AddButton($Sender, 'ProfileLink');
   }

   public function DraftsController_Render_Before($Sender) {
      $this->_AddButton($Sender, 'Discussion');
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender, 'ProfileLink');
    }
   
   public function MessagesController_Render_Before($Sender) {
      $this->_AddButton($Sender, 'Conversation');
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender, 'ProfileLink');

   }

   public function PostController_Render_Before($Sender) {
      $this->_AddButton($Sender, 'Discussion');
      $this->_AddButton($Sender, 'MobileHome');
      $this->_AddButton($Sender, 'ProfileLink');
   }
   
   private function _AddButton($Sender, $ButtonType) {
      if (is_object($Sender->Menu)) {
         if ($ButtonType == 'Discussion')
            $Sender->Menu->AddLink('NewDiscussion', Img('themes/mobile/design/images/new.png', array('alt' => T('New Discussion'))), '/post/discussion'.(array_key_exists('CategoryID', $Sender->Data) ? '/'.$Sender->Data['CategoryID'] : ''), array('Garden.SignIn.Allow'), array('class' => 'NewDiscussion'));
         elseif ($ButtonType == 'Conversation')
            $Sender->Menu->AddLink('NewConversation', Img('themes/mobile/design/images/new.png', array('alt' => T('New Conversation'))), '/messages/add', '', array('class' => 'NewConversation'));
elseif ($ButtonType == 'MobileHome')
            $Sender->Menu->AddLink('MobileHome', Img('/themes/mobile/mhicon.png', array('alt' => T('MobileHome'))), '/plugin/MobileHome',  array('class' => 'MobileHome'));
 elseif ($ButtonType == 'Categories')           
           $Sender->Menu->AddLink('Categories', T('Categories'),'/categories/all');
elseif ($ButtonType == 'ProfileLink')
$photo = UserPhoto(Gdn::Session()->User);           
 $Sender->Menu->AddLink('User',  $photo,  '/profile/{UserID}/{Username}',array('Garden.SignIn.Allow'), array('class' => 'UserNotifications'));
      }
   }
   
   // Change all pagers to be "more" pagers instead of standard numbered pagers
 
  public function DiscussionsController_BeforeBuildPager_Handler($Sender) {
      $Sender->EventArguments['PagerType'] = 'MorePager';
   }
   
   public function DiscussionController_BeforeBuildPager_Handler($Sender) {
      $Sender->EventArguments['PagerType'] = 'MorePager';
      $Sender->AddJsFile('jquery.gardenmorepager.js');
   }
   
   public function DiscussionController_BeforeDiscussion_Handler($Sender) {
      echo $Sender->Pager->ToString('less');
   }
   
   public function DiscussionController_AfterBuildPager_Handler($Sender) {
      $Sender->Pager->LessCode = 'Older Comments';
      $Sender->Pager->MoreCode = 'More Comments';
   }
   
   public function DiscussionsController_AfterBuildPager_Handler($Sender) {
      $Sender->Pager->MoreCode = 'More Discussions';
   }

}

then you need some css to finish the job

.Banner ul li a.NewDiscussion img,.Banner ul li a.NewConversation img {
vertical-align:middle;
}

.Banner ul li a {
display: block;
height: 35px!important;
}
.Banner ul li a img{
height: 35px!important;
margin-top: -5px;
}

.Banner ul li a.UserNotifications {
display: none;
}
 .Banner ul li a .ProfilePhotoMedium{
border-radius:0!important;
box-shadow:none;
height: 35px;
}

The last step Is to delete the profile link from the default.master.tpl

remove the part {profile_link}

hgtonightDavidShine

Comments

Sign In or Register to comment.