Thread: Code help
View Single Post
  #5  
Old 01-09-2010, 09:13 PM
solboy solboy is offline
 
Join Date: Jun 2002
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Most likely what you need to change are the templates and the syntax to render the templates. Cellarius wrote a really good article that you may be interested in - [vB4] Rendering templates and registering variables - a short guide
Thanks. I know of this and I have tried. This is as far as I got:

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="pblatestthreads" active="1">
	<title>PB Latest Threads</title>
	<description>Show the latest threads with transition effects.</description>
	<version>1.0</version>
	<url />
	<versioncheckurl />
	<dependencies>
	</dependencies>
	<codes>
	</codes>
	<templates>
		<template name="pb_latestthreads_area" templatetype="template" date="1237182817" username="admin" version="1.0"><![CDATA[<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="tcat">Latest Threads</td>
</tr>
<tr>
	<td class="alt1">

<div id='mid'>

<div id='slideshow'>

<div class="pbslide_container">
<div class="pbslide_inner" >
$pblatest_bigblocks
</div>
<div class="pbslide_bottombar">
$pblatest_smallblocks
</div>
</div><br/>
	<script type="text/javascript">
		var timeouts=new Array();
		var curframe=1;
		var start_frame=1;
		var end_frame=$pblimit;
		var oldframe=$pblimit;
		var TimeToFade = 700;
		var delay=5000;
		pbstart_slideshow(delay);
	</script>	
</div>

</div>
</td>
</tr>
</table>
]]></template>
		<template name="pb_latestthreads_bigblock" templatetype="template" date="1237182417" username="admin" version="1.0"><![CDATA[	<div class="pbslide_innerbox" $pbstyle id="pbslide$pbcount">
		<div class="pbslide_innercontent" >
		<a href="showthread.php?t=$pbthreadid">$pbthreadtitle</a><br/>
		<span>by $pbthreadstarter - $pbthreaddate</span><br/>
			$pbpagetext	
		</div>
	</div>]]></template>
		<template name="pb_latestthreads_smallblock" templatetype="template" date="1237420070" username="admin" version="1.0"><![CDATA[	<div class="pbslide_titles">
		<img $pbimage id="pbslide_b$pbcount" style="border:0;padding:0px;margin:0px;" alt=""/>
		<a href="showthread.php?goto=newpost&t=$pbthreadid" class="smallfont" title="$pbpagetext">$pbthreadtitle2</a>
		&nbsp;&nbsp;-&nbsp;Last Post: $pblastposttime by $pblastposter >> Replies: $pbreplies >> Views: $pbviews 
	</div>]]></template>
	</templates>
	<plugins>
		<plugin active="1" executionorder="5">
			<title>pb_latestthreads_cache</title>
			<hookname>cache_templates</hookname>
			<phpcode><![CDATA[global $globaltemplates;
$globaltemplates = array_merge($globaltemplates, array('pb_latestthreads_bigblock','pb_latestthreads_smallblock','pb_latestthreads_area'));]]></phpcode>
		</plugin>
		<plugin active="1" executionorder="5">
			<title>pb_latestthreads_global</title>
			<hookname>global_setup_complete</hookname>
			<phpcode><![CDATA[global $vbulletin;
$pbwhere=$vbulletin->options['pb_latest_whereto'];
if($pbwhere==0 or ($pbwhere==1 and THIS_SCRIPT=='index')or ($pbwhere==2 and THIS_SCRIPT=='forumdisplay') or ($pbwhere==3 and((THIS_SCRIPT=='index')or (THIS_SCRIPT=='forumdisplay')))){
$pbforumids=$forumids;
	// forum permissions
	$pbforumpermissions = array();
	foreach($vbulletin->forumcache AS $pbforum)
	{
		$pbforumpermissions[$pbforum["forumid"]] = fetch_permissions($pbforum['forumid']);
		if ((!($pbforumpermissions[$pbforum["forumid"]] & $vbulletin->bf_ugp_forumpermissions['canview'])) OR (!($pbforum['options'] & $vbulletin->bf_misc_forumoptions['active']) AND !$vbulletin->options['showprivateforums'] AND !in_array($vbulletin->userinfo['usergroupid'], array(5,6,7))))
		{
			$pbforumids .= ','.$pbforum['forumid'];
		}
	}
	if ($vbulletin->options['pbslide_exclude']!='' and isset($vbulletin->options['pbslide_exclude']))
	{
		$pbforumids .= ','.$vbulletin->options['pbslide_exclude'];
	}
	$pbforumids = substr($pbforumids, 1);
	if ($pbforumids!='')
	{
		$pblatest_and = "thread.forumid NOT IN($pbforumids)";
		$pblatest_and_1 = "forum.forumid NOT IN($pbforumids)";
	}
	
	// converts options to nice variables
	$pblimit = $vbulletin->options['pbslide_numthreads'];
	
	// query to get the last posts
	$pbquery = $vbulletin->db->query_read("
		SELECT
			thread.forumid as forumid, thread.visible, thread.title as thread_title, thread.threadid as threadid, thread.postusername as username, thread.postuserid as userid, thread.dateline as date, thread.lastposter as lastposter, thread.lastpost as lastpost, thread.replycount as replies, thread.views as views,
			forum.title as forum_title,
			post.postid, post.pagetext as pagetext
		FROM " . TABLE_PREFIX . "post as post
		LEFT JOIN " . TABLE_PREFIX . "thread as thread on (thread.firstpostid = post.postid)
		LEFT JOIN " . TABLE_PREFIX . "forum as forum on (thread.forumid = forum.forumid)
		WHERE thread.visible = 1 AND $pblatest_and AND $pblatest_and_1
		ORDER BY thread.lastpost DESC
		LIMIT $pblimit"
	);

	// reset variables
	$pbcount = 0;
	$pblatest_bigblocks = '';
	$pblatest_smallblocks='';
	
	while ($pbrow = $vbulletin->db->fetch_array($pbquery))
	{
		// allow to use alternate color in rows

		
		// strips the bbcode out of the post
		$pbrow['pagetext'] = strip_bbcode($pbrow['pagetext'], $stripquotes = true, $fast_and_dirty = false, $showlinks = true);
		
		// adds the cutoff ... with substr
	    $pbrow['pagetext'] = substr($pbrow['pagetext'], 0, $vbulletin->options['pbslide_cutoff']) . '...';
	    $pbthreadtitle2 = substr($pbrow['thread_title'], 0, $vbulletin->options['pbslide_cutoff_titles']) . '...';

		// convert pagetext to nice looking variable
		$pbpagetext = $pbrow['pagetext'];
		$pbthreadstarter = $pbrow['username'];
		$pbuserid = $pbrow['userid'];
		$pbforumid = $pbrow['forumid'];
		$pbthreadid = $pbrow['threadid'];
		$pbforumtitle = $pbrow['forum_title'];
		$pbthreadtitle = $pbrow['thread_title'];
		$pbthreaddate = vbdate($vbulletin->options['dateformat'], $pbrow['date'], true)." at ".vbdate($vbulletin->options['timeformat'], $pbrow['date']);
		$pblastposttime = vbdate($vbulletin->options['dateformat'], $pbrow['lastpost'], true)." at ".vbdate($vbulletin->options['timeformat'], $pbrow['lastpost']);
		$pblastposter=$pbrow['lastposter'];
		$pbviews=$pbrow['views'];
		$pbreplies=$pbrow['replies'];
		// increments the counter +1
		$show['latest_break'] = $pbcount++;
		if($pbcount==1){
		 $pbstyle="";
		 $pbimage="src=\"images/button.png\"";
		}
		else{
		 $pbstyle="style=\"display:none;opacity:0;filter:alpha(opacity =0)\"";
		 $pbimage="src=\"images/button2.png\"";
		}
		//eval('$pblatest_bigblocks .= "' . fetch_template('pb_latestthreads_bigblock') . '";');
		$templater->register('pb_latestthreads_bigblock', $pblatest_bigblocks);
		$pblatest_bigblocks = $templater->render();  
		//eval('$pblatest_smallblocks .= "' . fetch_template('pb_latestthreads_smallblock') . '";');
		templater->register('pb_latestthreads_smallblock', $pblatest_smallblocks);
		$pblatest_smallblocks = $templater->render();  
	}
	
	// free the query
	$vbulletin->db->free_result($pbquery);
	
	//eval('$PBLatestThreads = "' . fetch_template('pb_latestthreads_area') . '";');	
	$templater = vB_Template::create('mytemplate');
    $templater->register('pb_latestthreads_area', $PBLatestThreads);    
	$PBLatestThreads = $templater->render();  
	}
	else{
	$PBLatestThreads ='';
	}]]></phpcode>
		</plugin>
	</plugins>
	<phrases>
		<phrasetype name="vBulletin Settings" fieldname="vbsettings">
			<phrase name="setting_pb_latest_whereto_desc" date="1239304462" username="admin" version="1.0"><![CDATA[Where do you want to display the latest threads.]]></phrase>
			<phrase name="setting_pb_latest_whereto_title" date="1239304462" username="admin" version="1.0"><![CDATA[Where to show?]]></phrase>
			<phrase name="setting_pbslide_cutoff_desc" date="1237179560" username="admin" version="1.0"><![CDATA[Number of characters before the pagetext gets off]]></phrase>
			<phrase name="setting_pbslide_cutoff_title" date="1237179560" username="admin" version="1.0"><![CDATA[Post text cutoff]]></phrase>
			<phrase name="setting_pbslide_cutoff_titles_desc" date="1237179573" username="admin" version="1.0"><![CDATA[The amount of characters displayed before thread titles are cutoff.]]></phrase>
			<phrase name="setting_pbslide_cutoff_titles_title" date="1237179573" username="admin" version="1.0"><![CDATA[Title Cutoff]]></phrase>
			<phrase name="setting_pbslide_exclude_desc" date="1237179585" username="admin" version="1.0"><![CDATA[Put the forum ID's of the forums you want to exclude seperated by commas]]></phrase>
			<phrase name="setting_pbslide_exclude_title" date="1237179585" username="admin" version="1.0"><![CDATA[Exclude Forums]]></phrase>
			<phrase name="setting_pbslide_numthreads_desc" date="1237183072" username="admin" version="1.0"><![CDATA[The number of threads to display.]]></phrase>
			<phrase name="setting_pbslide_numthreads_title" date="1237183072" username="admin" version="1.0"><![CDATA[Number of Threads]]></phrase>
			<phrase name="settinggroup_pbslide_latestthreads" date="1237175444" username="admin" version="1.0"><![CDATA[PB Latest Threads]]></phrase>
		</phrasetype>
	</phrases>
	<options>
		<settinggroup name="pbslide_latestthreads" displayorder="65535">
			<setting varname="pbslide_exclude" displayorder="10">
				<datatype>free</datatype>
				<defaultvalue>1</defaultvalue>
			</setting>
			<setting varname="pbslide_cutoff" displayorder="20">
				<datatype>number</datatype>
				<defaultvalue>100</defaultvalue>
			</setting>
			<setting varname="pbslide_cutoff_titles" displayorder="30">
				<datatype>number</datatype>
				<defaultvalue>20</defaultvalue>
			</setting>
			<setting varname="pbslide_numthreads" displayorder="40">
				<datatype>number</datatype>
				<defaultvalue>5</defaultvalue>
			</setting>
			<setting varname="pb_latest_whereto" displayorder="50">
				<datatype>free</datatype>
				<optioncode>select:piped
0|Everywhere
1|ForumHome Only
2|ForumDisplay Only
3|ForumDisplay and ForumHome</optioncode>
			</setting>
		</settinggroup>
	</options>
	<helptopics>
	</helptopics>
	<cronentries>
	</cronentries>
	<faqentries>
	</faqentries>
</product>
Maybe you can see what I did wrong or what I missed.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01249 seconds
  • Memory Usage 1,837KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete