Pages

Showing posts with label Link. Show all posts
Showing posts with label Link. Show all posts

Wednesday, July 17, 2013

Web Development/Jquery/Javascript-Set a menu Link "selected" class if its href matches page url

Here is a simple js code with HTML to set a "seected" class to menu item when its corresponding page is open.

 <dl class="sidebarBox">  
   <dt>Mailboxes</dt>  
   <dd>  
     <ul class="mailbar">  
       <li><a href="inbox"><b>Inbox</b></a></li>  
       <li><a href="sent">Sent</a></li>  
       <li><a href="trash">Trash</a></li>  
     </ul>  
   </dd>  
 </dl>  
 <script type="text/javascript">  
   var winpath=window.location.pathname;  
   $(".mailbar li a").each(function(index)  
   {  
     var menupath=$(this).attr('href');  
     if(menupath==winpath)  
       $(this).parent().addClass("current");  
     else  
       $(this).parent().removeClass("current");  
   });  
 </script>  

Friday, May 3, 2013

Social Engine 4-Get avtar of user

$user_id=Engine_Api::()_->user->getviewer->getIdentity();

$userinfo=Engine_Api::_()->user()->getUser($user_id);

$photo_id=$user_info['photo_id'];


//Fetches table Engine4_storage_files

$filesTable=Engine_APi::_()->getDbtable('files','storage');

$adapter=Engine_Db_Table::getDefaultAdapter();

$filesTableName=$filesTable->info('name');

$query=Engine_Db_Table::getDefaultAdapter()->select("storage_path")->from($statsTableName)->where("field_id=?",$photo_id)->limit(1);

$result=$query->query()->fetch();

$result['storage_path'] //has the path to your photo


Sunday, April 21, 2013

Stop a link from reloading page

Place Javascript:void(0) for the href property.

or Javascript:return 0 and your page will not reload it self on click of the link.