vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   display last written blog article (https://vborg.vbsupport.ru/showthread.php?t=285455)

ohadpartuck 07-12-2012 10:49 AM

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
:D

kh99 07-12-2012 11:10 AM

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).

ohadpartuck 07-12-2012 12:28 PM

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

I tried :
1. vB_Template::preRegister('FORUMHOME',array(
'last_article' => $latestentry['blogtitle']
));
2. $template_hook['last_article'] = $latestentry['blogtitle'];

kh99 07-12-2012 02:16 PM

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>';
}


ohadpartuck 07-12-2012 03:15 PM

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..

kh99 07-12-2012 03:24 PM

Quote:

Originally Posted by ohadpartuck (Post 2347307)
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).

ohadpartuck 07-15-2012 05:25 AM

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
)); 



All times are GMT. The time now is 05:26 AM.

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.01133 seconds
  • Memory Usage 1,745KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete