Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-09-2010, 08:25 PM
solboy solboy is offline
 
Join Date: Jun 2002
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Code help

......
Reply With Quote
  #2  
Old 01-09-2010, 08:52 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is this code *you* wrote? And if not, do you have permission from the author to post it? If not, you may NOT post it here.
Reply With Quote
  #3  
Old 01-09-2010, 09:02 PM
solboy solboy is offline
 
Join Date: Jun 2002
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Is this code *you* wrote? And if not, do you have permission from the author to post it? If not, you may NOT post it here.
I own this mod. I paid to have it created for vb. 3.8.
Look around and see if it's anywhere on this board or anywhere else unless I posted it. If you can assist then I would be very happy.
Reply With Quote
  #4  
Old 01-09-2010, 09:08 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #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
  #6  
Old 01-09-2010, 09:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You also need to change the template syntax as noted in the article here:
Quote:
In the template you know will be able to use the registered variables/arrays in this way:

HTML Code:
{vb:raw my_var}
{vb:raw my_array.key1}
{vb:raw my_array.key2.key21}
Reply With Quote
  #7  
Old 01-09-2010, 09:32 PM
solboy solboy is offline
 
Join Date: Jun 2002
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
You also need to change the template syntax as noted in the article here:
Thanks allot. Forgive me for being a novice but I have no idea where those are to go in the code or what to change.
Reply With Quote
  #8  
Old 01-09-2010, 09:44 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

They are variables. So, instead of $my_variable, you would use {vb:raw my_variable}
Reply With Quote
  #9  
Old 01-09-2010, 09:48 PM
solboy solboy is offline
 
Join Date: Jun 2002
Posts: 111
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
They are variables. So, instead of $my_variable, you would use {vb:raw my_variable}
Ok thanks. Let me see what I can do.

--------------- Added [DATE]1263084199[/DATE] at [TIME]1263084199[/TIME] ---------------

I tried all that I can. It's not working. can someone make the edits needed for me and post it here please?

--------------- Added [DATE]1263084258[/DATE] at [TIME]1263084258[/TIME] ---------------

Quote:
Originally Posted by Lynne View Post
You also need to change the template syntax as noted in the article here:
Thanks for your help but this looks like it's notworking for me. I just don't know how.
Reply With Quote
  #10  
Old 01-10-2010, 05:41 AM
cellarius's Avatar
cellarius cellarius is offline
 
Join Date: Aug 2005
Posts: 1,987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In the code given above, I see lots of variables used in the template that are not registered, like $pbstyle, $pbthreadid, $pbthreadtitle etc. Basically none of the variables you use in the template are registered. Please read the tutorial Lynne linked you to again, especially the part about "Save into a variable for later use in custom template".

For $threadid for example, you need to register the variable for your bigblock template and for your smallblock template:
PHP Code:
$templater->register('pb_latestthreads_bigblock'$pblatest_bigblocks);
   
$templater->register('threadid'$threadid);
$pblatest_bigblocks .= $templater->render(); 
What I changed: Added the $templater->register line to register $threadid. Added the dot in the last line before the =, since this is in a while-loop and you don't want the result to be overwritten every time, but added. Note how you had that point in your old eval, too.
Now you can call $threadid in your template pb_latestthreads_bigblock by inserting {vb:raw threadid}.

To be able to call the variable you saved the template into ($pblatest_bigblock) in your pb_latestthreads_area template, you again need to register it:

Your code there:
PHP Code:
$templater vB_Template::create('mytemplate');
    
$templater->register('pb_latestthreads_area'$PBLatestThreads);    
    
$PBLatestThreads $templater->render(); 
This cannot work. Note how you did not insert the template name (it still reads mytemplate!) in first line. Then, in second line, you don't register an existing variable you want to use in the template, but try to register the variable you want to save the template into. This makes no sense: You don't want to call that template inside that very template. Here you would register the variable you saved the bigblocks template into, to be able to call it in the latestthreads area template. Furthermore, you need to decide where you want to call this last template, the area template. If you want to show the contents of your latestthreads_area template on forumhome, for example, you'd need to preregister it for that.

IT would look something like that:
PHP Code:
$templater vB_Template::create('pb_latestthreads_area'); // create the template
    
$templater->register('pblatest_bigblocks'$pblatest_bigblocks); // register $pblatest_bigblocks to be able to use {vb:raw pblatest_bigblocks} in template pb_latestthreads_area
    
$templatevalues['PBLatestThreads'] = $templater->render(); // rendering template into a variable suitable for preregistering for use in existing template 
    
vB_Template::preRegister('FORUMHOME'$templatevalues); // preregister variable from line above to be able to use {vb:raw PBLatestThreads} on forumhome 
I would like to advice you to first go with some simple hello world examples to learn the logic of registering templates. Your construction is quite complicated to start with. If you want to look at a code example, download my social groups on forum home mod - it uses basically the same construction.

Basically:
- bigblock template: register every variable you want to use inside this template, save into variable
- smallblock template: register every variable you want to use inside this template, save into variable
- area template: register every variable you want to use inside this template, including the variables you saved bigblock and smallblock templates into; save area template into variable, then preregister this variable for use in existing template
Reply With Quote
Reply

Thread Tools
Display Modes

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 04:50 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.06117 seconds
  • Memory Usage 2,292KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete