Author Topic: [CODE] - User Blogs On Profile (Extends existing blog widget)  (Read 575 times)

KHDev

  • Global Moderator
  • Veteran Member
  • *****
  • Posts: 501
  • Karma: +43/-2
  • Etano Contributor (Skins & Mods)
    • KH Web Development
[CODE] - User Blogs On Profile (Extends existing blog widget)
« on: October 26, 2015, 09:56:39 AM »
This is little tweak extends the blogs widget so you can add user blogs on their profile. By default it will show the latest 3 blog posts by the user with a more link to view all. If the user has no blogs then the widget will not show.

Note! Any line reference is approximate and may differ if you have modified blogs.class.php previously.

Open  plugins > widget > blogs > blogs.class.php

Around line 59 add:

Code: [Select]
<?php ### IGNORE THIS LINE ###
case 'user':
$buser=$this->config['user'];
$query.=" AND a.`fk_user_id`='$buser' ORDER BY a.`date_posted` DESC ";
break;


Around line 123  add:

Code: [Select]
<?php ### IGNORE THIS LINE ###

case 'user':
$widget['title']='Blogs';
$widget['id']='widg_user_blogs';
break;


Around line 129 find

Code: [Select]
<?php ### IGNORE THIS LINE ###

#### FIND THIS LINE #####

$widget['action']='<a class="content-link link_more" href="'.$GLOBALS['tplvars']['relative_url'].'blog_search.php?st='.$this->config['mode'].'" title="'.$GLOBALS['_lang'][205].'">'.$GLOBALS['_lang'][205].'</a>';

##### CHANGE IT TO ######

if (isset($this->config['user'])) {
$widget['action']='<a class="content-link link_more" href="'.$GLOBALS['tplvars']['relative_url'].'blog_search.php?st=uid&uid='.$this->config['user'].'" title="'.$GLOBALS['_lang'][205].'">'.$GLOBALS['_lang'][205].'</a>';
} else {
$widget['action']='<a class="content-link link_more" href="'.$GLOBALS['tplvars']['relative_url'].'blog_search.php?st='.$this->config['mode'].'" title="'.$GLOBALS['_lang'][205].'">'.$GLOBALS['_lang'][205].'</a>';
}





Save it.



Now open, skins_site > def > profile.html

and simply use this to add the blogs widget to the profile

Code: [Select]
<!--widget="blogs(array('mode'=>'user','total'=>3,'user'=>{output.uid}))"-->

Save it.

And that should be it :)