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

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2012, 05:45 PM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Need to call up custom field in "lastpostby" template

I need to be able to call up a custom field - "field12" in the "forumhome_lastpostby" template.

I've tried numerous plugins and hooks (including forumbit_display) but still can't get the information to display in the "lastpostby" section.


I was able to get it to work fine on forumdisplay using using hook "forumdisplay_query" and this plugin code:

Code:
$hook_query_fields .= ', userfield.field12 ';
$hook_query_joins .= ' LEFT JOIN ' . 'userfield AS userfield ON (userfield.userid = thread.postuserid) ';
Reply With Quote
  #2  
Old 12-18-2012, 06:27 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You would need to run a query to get that information since all of the lastpostby information is cached and it doesn't include field12.
Reply With Quote
  #3  
Old 12-18-2012, 09:40 PM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I knew there had to be something different. Thanks for the heads up on the caching and need for a query.

I'm still pretty novice at this so if someone has some step by step on how to do this or a place I can go to read up on it it would be appreciated. Thanks.
Reply With Quote
  #4  
Old 12-18-2012, 10:15 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I started thinking about this when you first posted but Lynne beat me to answering. Anyway, I think this works, using hook location cache_ordered_forums:

Code:
if (THIS_SCRIPT == 'index')
{
    $tachyjoin .= " LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON (forum.lastposterid = userfield.userid) ";
    $counter_select .= ", userfield.field12";
}
and then use {vb:raw lastpostinfo.field12} in the template.

But that only works on the home page. Getting it to work in the threadbit template on the forumdisplay page is a different issue.
Reply With Quote
  #5  
Old 12-18-2012, 11:39 PM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Couldn't get that to work.
Reply With Quote
  #6  
Old 12-18-2012, 11:48 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm...I actually tried it and it seems to work. But maybe I'm doing something differently. But like I mentioned, it only works for the home page.

I just now noticed that you were doing something really similar in your first post, maybe something like that would work for the forumdisplay pages.
Reply With Quote
  #7  
Old 12-19-2012, 12:13 AM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think I figured out the issue.

I had mod "Vsa Last Post Info Enhancements" installed. Which already has a join. When disabled your code does work.

Can you look at his plugin code and see if it can be modified to include this. Thanks.

Code:
if ($vbulletin->options['vsalpienh_enable_global'] AND ($forum[vsa_lpienhancements]>1) AND ($forum[threadcount]!=0))
		{
			$vsa_lpi_forumperms = $vbulletin->userinfo['forumpermissions'][$forumid];
			if (($vsa_lpi_forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads'] OR can_moderate()) AND (($vsa_lpi_forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) OR can_moderate()) AND (($forum['options'] & $vbulletin->bf_misc_forumoptions['active']) OR can_moderate()))
			{
				if ($vbulletin->options['apboupc_global_enable'])
				{
					$vsa_lpi_vsaapbouc_excgroups = explode(",",$vbulletin->options['apboupc_forum_excludedgroups']);
				}
				$vsa_lpi_childperms = array($forum[childlist]);
				$vsalpi_exclfids = '';
				foreach($vbulletin->forumcache AS $vsalpi_child)
				{
					$vsa_lpi_childperms[$vsalpi_child["forumid"]] = fetch_permissions($vsalpi_child['forumid']);
					if ((!($vsa_lpi_childperms[$vsalpi_child["forumid"]] & $vbulletin->bf_ugp_forumpermissions['canview'])) OR (!($vsalpi_child['options'] & $vbulletin->bf_misc_forumoptions['active']) AND !$vbulletin->options['showprivateforums'] AND !can_moderate()) OR ($vbulletin->options['apboupc_global_enable'] AND ($vsalpi_child['accessf_nb']>$vbulletin->userinfo['posts']) AND !is_member_of($vbulletin->userinfo, $vsa_lpi_vsaapbouc_excgroups)))
					{
						$vsalpi_exclfids .= ','.$vsalpi_child['forumid'];
					}
				}
				unset($vsalpi_child);

				if (($vbulletin->options['vsalpienh_excl_forums']!='') AND !can_moderate())
				{
					$vsalpi_exclfids .= ','.$vbulletin->options['vsalpienh_excl_forums'];
				}
				$vsalpi_exclfids = substr($vsalpi_exclfids, 1);
				if ($vsalpi_exclfids!='')
				{
					$vsalpi_exclforums = "AND forumid NOT IN($vsalpi_exclfids)";
				}

				$vsalpi_results = $forum[vsa_lpienhancements];
				$GLOBALS['vbulletin']->db->hide_errors();
				$vsalpi_getinfo = $GLOBALS['vbulletin']->db->query_read("
					SELECT thread.threadid, thread.title, thread.lastpost, thread.lastpostid, thread.lastposter, thread.lastposterid, thread.iconid, thread.prefixid, user.userid, user.username
					FROM " . TABLE_PREFIX . "thread AS thread
					LEFT JOIN  " . TABLE_PREFIX . "user AS user ON (user.userid = thread.lastposterid)
					WHERE threadid>0 AND visible=1 AND open!=10 AND forumid IN($forum[childlist]) $vsalpi_exclforums
					ORDER BY lastpost DESC
					LIMIT 0, $vsalpi_results
				");
				$GLOBALS['vbulletin']->db->show_errors();
				$vsalpi_restot = $GLOBALS['vbulletin']->db->num_rows($vsalpi_getinfo);

				$vsalpi_lastpost = '';
				while ($lastpostinfo = $GLOBALS['vbulletin']->db->fetch_array($vsalpi_getinfo))
				{
					$icon = fetch_iconinfo($lastpostinfo['iconid']);
					if ($lastpostinfo['prefixid'] AND $vbulletin->options['vsalpienh_enable_prefix'])
					{
						$vsalpi_tprefix = ($vbulletin->options['vsalpienh_enable_prefix'] == 2 ?
							$vbphrase["prefix_$lastpostinfo[prefixid]_title_rich"] :
							htmlspecialchars_uni($vbphrase["prefix_$lastpostinfo[prefixid]_title_plain"])
						);
					}
					else
					{
						$vsalpi_tprefix = '';
					}
					$lastpostinfo[lastthreadid] = $lastpostinfo[threadid];
					$lastpostinfo[lastthread] = strip_tags($lastpostinfo[title]);

					$vsalpi_statusicon = '';
					if ($vbulletin->options['vsalpienh_enable_statusicons'])
					{
						if ($lastpostinfo[lastpost]>$vbulletin->userinfo['lastvisit'])
						{
							$vsalpi_statusicon = '<img class="inlineimg" src="'.vB_Template_Runtime::fetchStyleVar('imgdir_statusicon').'/post_new.png" alt="'.$vbphrase['new'].'" border="0" width="8" height="8" /> ';
						}
						else
						{
							$vsalpi_statusicon = '<img class="inlineimg" src="'.vB_Template_Runtime::fetchStyleVar('imgdir_statusicon').'/post_old.png" alt="'.$vbphrase['old'].'" border="0" width="8" height="8" />  ';
						}
					}
					$vsalpi_memberaction_dropdown = construct_memberaction_dropdown(fetch_userinfo($lastpostinfo['userid']));  
					$lastpostinfo_unreadpost = fetch_seo_url('thread', $lastpostinfo, array('goto' => 'newpost'));
					$lastpostinfo_lastpost = fetch_seo_url('thread', $lastpostinfo, array('p' => $lastpostinfo['lastpostid'])) . '#post' . $lastpostinfo['lastpostid'];
					$lastpostinfo['trimthread'] = fetch_trimmed_title(fetch_censored_text($lastpostinfo['lastthread']));
					$lastpostinfo['lastpostdate'] = vbdate($vbulletin->options['dateformat'], $lastpostinfo['lastpost'], 1);
					$lastpostinfo['lastposttime'] = vbdate($vbulletin->options['timeformat'], $lastpostinfo['lastpost']);

					$templater = vB_Template::Create('vsa_lastpostsinfo_bit');
					$templater->register('lastpostinfo', $lastpostinfo);
					$templater->register('vsalpi_memberaction_dropdown', $vsalpi_memberaction_dropdown);
					$templater->register('lastpostinfo_unreadpost', $lastpostinfo_unreadpost);
					$templater->register('lastpostinfo_lastpost', $lastpostinfo_lastpost);
					$templater->register('vsalpi_tprefix', $vsalpi_tprefix);
					$templater->register('vsalpi_statusicon', $vsalpi_statusicon);
					$templater->register('icon', $icon);
					$vsalpi_lastpost .= $templater->render();
				}
				unset($lastpostinfo,$vsalpi_getinfo);

				if ($vsalpi_restot > 1)
				{
					$vsalpi_preins = array(1,2);
					foreach ($vsalpi_preins AS $foo)
					{
						$vsalpi_lastposts = "";
						if ($vbulletin->options['vsalpienh_enable_title'])
						{
							$vsalpi_lastposts .= construct_phrase($vbphrase[vsalpienh_last_x_posts], $vsalpi_restot);
						}
						$vsalpi_lastposts .= $vsalpi_lastpost;
						global $vsalpi_lastposts;
						$forum['lastpostinfo'] = $vsalpi_lastposts;
					}
				}
			}
		}
Reply With Quote
  #8  
Old 12-19-2012, 12:59 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Which hook is that on? And were you getting an error or just not seeing anything? I don't see anything in that code that would interfere with what I posted, but maybe it's just that you would need to make your changes to the vsa_lastpostsinfo_bit template instead.
Reply With Quote
  #9  
Old 12-19-2012, 01:29 AM
bzcomputers's Avatar
bzcomputers bzcomputers is offline
 
Join Date: Apr 2012
Location: TX
Posts: 503
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hook is on "forumbit_display".

It may have just been a caching issue. After clearing cache they do seem to be playing well together now.

Looks like I'll now need to figure out how to get the plugin above to show the "field12" also.

Edit: They may not be working together as well as I thought. Seems like with the plugin from Post #4 above enabled, on page refresh the Vsa mod will sometimes work and sometimes not.
Reply With Quote
  #10  
Old 12-19-2012, 01:59 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's really strange. That mod doesn't use the same hook that my code does, and I'm pretty sure what I posted doesn't do anything except add one field to the forumcache. But I didn't really study that code - maybe there's something about that extra field that's causing the problem?
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 05:43 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.02232 seconds
  • Memory Usage 2,263KB
  • Queries Executed 11 (?)
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)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_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