The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
I searched for a few terms but couldn't really find anything helpful. I've been trying for the past couple hours trying to get this to work. I'm trying to pull thread information from the latest one posted in our News forum and display bits of it in the HEADER template.
I've also tried putting the same code in FORUMHOME template in case it was something associated with the hook I chose but still does not work. I did something very similar to this on vBulletin 3.x (used the plugin code and called it via $news1_title, etc) but seems I'm missing something here. Also would like to note that this is pretty much ripped straight from my external news script, which I posted here for viewing (since I'm not using it on the site atm): http://pokemontopaz.net/sandbox/ Plugin code (using forumhome_complete hook): Code:
$postchars = 250; $news1 = $db->query_first('SELECT title,threadid,views,replycount,postusername,postuserid,dateline FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 4 ORDER BY dateline DESC LIMIT 0 , 1'); $news1_title = "<a href=\"forums/showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">$news1[title]</a>"; $news1_readmore = "<a href=\"forums/showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">[Read More]</a>"; $news1_comment = "<a href=\"forums/newreply.php?do=newreply&noquote=1&" . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">[Post Comment]</a>"; $news1_replies = "$news1[replycount]"; $news1_views = "$news1[views]"; $news1_post = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $news1[threadid] . ' ORDER BY dateline ASC LIMIT 0 , 1'); $news1_postfull = "$news1_post[pagetext]"; $news1_postshort = substr($news1_post[pagetext],0,$postchars); $news1_date = vbdate($vbulletin->options['dateformat'], $news1['dateline']); $news1_time = vbdate($vbulletin->options['timeformat'], $news1['dateline']); $news1_posturl = "<a href=\"forums/member.php?" . $news1[postuserid] . "\">" . $news1[postusername] . "</a>"; Code:
<div id="lugianewscontent"> <h3>$news1_title by $news1_posturl on $news1_date</h3> <p>$news1_postshort... [$news1_readmore]</p> <p>Replies: $news1_replies - Views: $news1_views $news1_comment</p> </div> |
#2
|
|||
|
|||
![]()
The problem is that the header has already been parsed by the time forumhome_complete is called. You'll want do so something like this in forumhome_complete:
PHP Code:
|
#3
|
|||
|
|||
![]()
Alright, I appreciate you getting me started. I also took a look at this guide and have made a little more progress.
I've hit a complete wall though and am unsure on how to proceed now. I created a template as you suggested (auto_news). I have two plugins now. One is using the cache_templates hook and has: Code:
$cache[] = 'auto_news'; Code:
$postchars = 250; $news1 = $db->query_first('SELECT title,threadid,views,replycount,postusername,postuserid,dateline FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 4 ORDER BY dateline DESC LIMIT 0 , 1'); $news1_title = "<a href=\"forums/showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">$news1[title]</a>"; $news1_readmore = "<a href=\"forums/showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">[Read More]</a>"; $news1_comment = "<a href=\"forums/newreply.php?do=newreply&noquote=1&" . $vbulletin->session->vars['sessionurl'] . "t=$news1[threadid]\">[Post Comment]</a>"; $news1_replies = "$news1[replycount]"; $news1_views = "$news1[views]"; $news1_post = $db->query_first('SELECT pagetext FROM ' . TABLE_PREFIX . 'post WHERE 1 AND threadid = ' . $news1[threadid] . ' ORDER BY dateline ASC LIMIT 0 , 1'); $news1_postfull = "$news1_post[pagetext]"; $news1_postshort = substr($news1_post[pagetext],0,$postchars); $news1_date = vbdate($vbulletin->options['dateformat'], $news1['dateline']); $news1_time = vbdate($vbulletin->options['timeformat'], $news1['dateline']); $news1_posturl = "<a href=\"forums/member.php?" . $news1[postuserid] . "\">" . $news1[postusername] . "</a>"; $vbulletin->templatecache['header'] .= eval(auto_news); Code:
<h3>$news1_title by $news1_posturl on $news1_date</h3> <p>$news1_postshort... [$news1_readmore]</p> <p>Replies: $news1_replies - Views: $news1_views $news1_comment</p> The div container is in the header template and I put {vb:raw auto_news} within the tags but it doesn't seem to be working. What am I missing? I can't figure it out... |
#4
|
||||
|
||||
![]()
the syntax in your template is all wrong - see this https://vborg.vbsupport.ru/showthread.php?t=221560 .
The way you are rendering the template is wrong - see this https://vborg.vbsupport.ru/showthread.php?t=228078 (or just read the code in the vbulletin files). What text are you ending up with using your current code? It would really help to know so we know where you are going wrong. When I have problems and need to troubleshoot, I totally simplify it all. Template code - <div> Hello! </div> - does it work? If not, you aren't getting the template called correctly. If it does work, put one variable in it - {vb:var testing} - and in the plugin put $testing = "Hello"; and see if that works. Just keep going at it that way to figure out where your problem is. |
#5
|
|||
|
|||
![]()
Sorry, I haven't had the time to get back to this but I'm trying again now.
I think I fixed my plugin code and my problem exists in calling the template. I've gone over the guide and I'm still unsure on how to call the template code to execute within the header template. I took your suggestion and simplified it all. testplugin code: Code:
$test = "hello"; $templater = vB_Template::create('testplate'); $templater->register('test', $test); $templater->render(); $vbulletin->templatecache['header'] .= eval('testplate'); testplate code: Code:
<p>{vb:var test}</p> Code:
<div id="lugianewscontent"> {vb:var testplate} </div> The end result is nothing at all. The lugianews div is simply blank. No error, no text, nothing. |
#6
|
||||
|
||||
![]()
I don't understand what you think this line does:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
|
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|