Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-12-2012, 10:49 AM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default display last written blog article

Hi,
I want to display the last written blog article on the top of my forum.
The information is in the template 'FORUMHOME' under:
{vb:raw template_hook.forumhome_wgo_stats}
but in there i get all the data I don't need also (number of blog, articles in the last 24h ).

So I need to know where can I extract the exact data I need.

Thanks
Reply With Quote
  #2  
Old 07-12-2012, 11:10 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's a good question - took me a while to figure it out. But the code that sets the blog stats on the forum home page is in the plugin "Forum Home: Process Blog Stats" (in the "Product : vBulletin Blog" section under the Plugin Manager).
Reply With Quote
  #3  
Old 07-12-2012, 12:28 PM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I found it , but how do I extract the last article tilte and who wrote it?

I tried :
1. vB_Template:reRegister('FORUMHOME',array(
'last_article' => $latestentry['blogtitle']
));
2. $template_hook['last_article'] = $latestentry['blogtitle'];
Reply With Quote
  #4  
Old 07-12-2012, 02:16 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's the structure of $vbulletin->blogstats, with junk from my test server.

Code:
Array
(
    [lastentry] => Array
        (
            [username] => Kevin
            [userid] => 1
            [title] => fdsasdfafsda
            [blogid] => 1
            [categories] => 
            [postedby_username] => Kevin
            [postedby_userid] => 1
            [blogtitle] => 
            [guestcanview] => 1
        )

    [total_blog_users] => 1
    [total_blog_entries] => 1
    [entries_in_24hours] => 1
)

So you probably want something like:

require_once(DIR . '/includes/blog_functions_shared.php');

Code:
if (is_array($vbulletin->blogstats) AND is_array($vbulletin->blogstats['lastentry']))
{
   $user = $vbulletin->blogstats['lastentry']['username'];
   $userid = $vbulletin->blogstats['lastentry']['userid'];
   $title = $vbulletin->blogstats['lastentry']['title'];
   $url = '<a href="' . fetch_seo_url('entry', array('blogid' => $vbulletin->blogstats['lastentry']['blogid'], 'title' => $title))	. 
			"\">" . $title . '</a>';
}
Reply With Quote
  #5  
Old 07-12-2012, 03:15 PM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks kh99,
1. i think you have a mistake in the $title = $user = .. row (don't know why you did that).
2. I am trying to also get the user link to his profile
I tried several ways (non worked ):
$link = 'http://www.s-maof.com/members/' . urlencode( $userid. '-'. preg_replace("/ /","-",$user));
$userlink = '<a href="'. $link . '" \>' . $user . '</a>';

i'm sutre there is an easier way..
Reply With Quote
  #6  
Old 07-12-2012, 03:24 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ohadpartuck View Post
thanks kh99,
1. i think you have a mistake in the $title = $user = .. row (don't know why you did that).
Just a cut and paste error - I was in a hurry.


Quote:
2. I am trying to also get the user link to his profile
I tried several ways (non worked ):
$link = 'http://www.s-maof.com/members/' . urlencode( $userid. '-'. preg_replace("/ /","-",$user));
$userlink = '<a href="'. $link . '" \>' . $user . '</a>';

i'm sutre there is an easier way..

What I posted was just meant to be some examples of getting the info, some of which might be useful. If you're trying to make a link to the user, maybe this:

Code:
$userlink  = '<a href="' . fetch_seo_url('member', array('userid' => $userid, 'username' => $user)) . '"/>' . $username . '<a/>';

(Sorry for any typos - I haven't actually tried this code).
Reply With Quote
  #7  
Old 07-15-2012, 05:25 AM
ohadpartuck ohadpartuck is offline
 
Join Date: Mar 2012
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks, kh99, it works,
but instead of the $username , you have to use $user according to this thread example.

So the whole plug in looks like this,

PHP Code:
require_once(DIR '/includes/blog_functions_shared.php');

if (
is_array($vbulletin->blogstats) AND is_array($vbulletin->blogstats['lastentry']))
{
   
$user $vbulletin->blogstats['lastentry']['username'];
   
$userid $vbulletin->blogstats['lastentry']['userid'];
   
$title =  $vbulletin->blogstats['lastentry']['title'];
   
$url '<a href="' fetch_seo_url('entry', array('blogid' => $vbulletin->blogstats['lastentry']['blogid'], 'title' => $title))    . 
            
"\">" $title '</a>';
  
$userlink  '<a href="' fetch_seo_url('member', array('userid' => $userid'username' => $user)) . '"/>' $user '<a/>';
}

vB_Template::preRegister('FORUMHOME',array(
'url' => $url,
'userlink' => $userlink
)); 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:03 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04059 seconds
  • Memory Usage 2,236KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (3)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete