The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
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) '; |
#2
|
||||
|
||||
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.
|
#3
|
||||
|
||||
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. |
#4
|
|||
|
|||
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"; } But that only works on the home page. Getting it to work in the threadbit template on the forumdisplay page is a different issue. |
#5
|
||||
|
||||
Couldn't get that to work.
|
#6
|
|||
|
|||
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. |
#7
|
||||
|
||||
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; } } } } |
#8
|
|||
|
|||
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.
|
#9
|
||||
|
||||
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. |
#10
|
|||
|
|||
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?
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|