Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
  #1  
Old 11-05-2004, 05:19 PM
RedWingFan's Avatar
RedWingFan RedWingFan is offline
 
Join Date: Oct 2004
Location: Canton, MI USA
Posts: 103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Announcement in Search Results Page

Since a lot of our members use the "New Posts" feature and don't browse the forums, they are missing important forum announcements. I would like to put the announcements at the top of the search results (which is how the New Posts page is generated). Here is a similar thread showing how to do this for "threadview":

https://vborg.vbsupport.ru/showthread.php?t=64281

I'm not familiar enough yet with vB (using 3.0.3 here) to know exactly where to put the appropriate pieces of code. And I have not yet been able to experiment.

TIA if you can help!
Reply With Quote
  #2  
Old 11-14-2004, 02:00 AM
RedWingFan's Avatar
RedWingFan RedWingFan is offline
 
Join Date: Oct 2004
Location: Canton, MI USA
Posts: 103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

*Bump.*

On the modification I linked to above, it shows a section of code. If I knew where to put this in search.php, I'm sure it could work without modification (or very minimal). Tried it already but didn't have any luck.

Dropping "$announcebits" into the template is a no-brainer, though.

Anyone?
Reply With Quote
  #3  
Old 11-14-2004, 10:50 AM
Ianomed's Avatar
Ianomed Ianomed is offline
 
Join Date: Oct 2004
Location: The Netherlands
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That code probably didn't work because of the missing forumID when you're in search

Is there any restriction on what forums it should pull the announcements through to the search results from, or can it simply be all of them?

If it's okay for all announcements to show, then this is the answer:

in search.php, find:
PHP Code:
// #############################################################################
if ($_REQUEST['do'] == 'showresults'
below, find:
PHP Code:
    // select the correct part of the forum jump menu
    
$frmjmpsel['search'] = 'class="fjsel" selected="selected"';
    
construct_forum_jump();

    
// add to the navbits
    
$navbits[''] = $vbphrase['search_results'];

    
$templatename 'search_results'
below add:
PHP Code:
    // announce bit hack

        
$announcebits '';

        
$announcements $DB_site->query("
                SELECT
                        announcementid, startdate, title, forumid, announcement.views,
                        user.username, user.userid, user.usertitle, user.customtitle
                FROM " 
TABLE_PREFIX "announcement AS announcement
                LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = announcement.userid)
                WHERE startdate <= " 
. (TIMENOW $vboptions['hourdiff']) . "
                        AND enddate >= " 
. (TIMENOW $vboptions['hourdiff']) . "
                ORDER BY startdate DESC
                " 
iif($vboptions['oneannounce'], "LIMIT 1"));

        while (
$announcement $DB_site->fetch_array($announcements))
        {
                if (
$announcement['customtitle'] == 2)
                {
                        
$announcement['usertitle'] = htmlspecialchars_uni($announcement['usertitle']);
                }
                        
$announcement['postdate'] = vbdate($vboptions['dateformat'], $announcement['startdate']);
                if (
$announcement['startdate'] > $lastread)
                {
                        
$announcement['statusicon'] = 'new';
                }
                else
                {
                        
$announcement['statusicon'] = 'old';
                }
                
$announcement['views'] = vb_number_format($announcement['views']);
        
$foruminfo['forumid']=$announcement['forumid'];
                
$announcementidlink iif(!$vboptions['oneannounce'] , "&amp;announcementid=$announcement[announcementid]");

                eval(
'$announcebits .= "' fetch_template('forumdisplay_announcement') . '";');
        }
    
    
// end announce bit hack 
find, near the top:
PHP Code:
// pre-cache templates used by all actions
$globaltemplates = array(
    
'search_forums',
    
'search_results',
    
'search_results_postbit'// result from search posts
    
'threadbit'// result from search threads
    
'newreply_reviewbit_ignore'
); 
replace with:
PHP Code:
// pre-cache templates used by all actions
$globaltemplates = array(
    
'search_forums',
    
'search_results',
    
'search_results_postbit'// result from search posts
    
'threadbit'// result from search threads
    
'newreply_reviewbit_ignore',
    
'forumdisplay_announcement'
); 
then in template search_results, add where you want them:
PHP Code:
<if condition="$announcebits">
    <
table class="tborder" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]border="0" width="100%" align="center" style="margin:$stylevar[cellpadding]px 0px $stylevar[cellpadding]px 0px">
        <
tr>
            <
td class="tcat" colspan="2">
                
$vbphrase[announcements]
            </
td>
        </
tr>
        
$announcebits
    
</table>
</if> 
That should do you

Edit: clarified the instructions.
Reply With Quote
  #4  
Old 11-14-2004, 01:32 PM
RedWingFan's Avatar
RedWingFan RedWingFan is offline
 
Join Date: Oct 2004
Location: Canton, MI USA
Posts: 103
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Ianomed
That code probably didn't work because of the missing forumID when you're in search

Is there any restriction on what forums it should pull the announcements through to the search results from, or can it simply be all of them?

If it's okay for all announcements to show, then this is the answer:

in search.php, find:
PHP Code:
// #############################################################################
if ($_REQUEST['do'] == 'showresults'
below, find:
PHP Code:
    // select the correct part of the forum jump menu
    
$frmjmpsel['search'] = 'class="fjsel" selected="selected"';
    
construct_forum_jump();

    
// add to the navbits
    
$navbits[''] = $vbphrase['search_results'];

    
$templatename 'search_results'
below add:
PHP Code:
    // announce bit hack

        
$announcebits '';

        
$announcements $DB_site->query("
                SELECT
                        announcementid, startdate, title, forumid, announcement.views,
                        user.username, user.userid, user.usertitle, user.customtitle
                FROM " 
TABLE_PREFIX "announcement AS announcement
                LEFT JOIN " 
TABLE_PREFIX "user AS user ON(user.userid = announcement.userid)
                WHERE startdate <= " 
. (TIMENOW $vboptions['hourdiff']) . "
                        AND enddate >= " 
. (TIMENOW $vboptions['hourdiff']) . "
                ORDER BY startdate DESC
                " 
iif($vboptions['oneannounce'], "LIMIT 1"));

        while (
$announcement $DB_site->fetch_array($announcements))
        {
                if (
$announcement['customtitle'] == 2)
                {
                        
$announcement['usertitle'] = htmlspecialchars_uni($announcement['usertitle']);
                }
                        
$announcement['postdate'] = vbdate($vboptions['dateformat'], $announcement['startdate']);
                if (
$announcement['startdate'] > $lastread)
                {
                        
$announcement['statusicon'] = 'new';
                }
                else
                {
                        
$announcement['statusicon'] = 'old';
                }
                
$announcement['views'] = vb_number_format($announcement['views']);
        
$foruminfo['forumid']=$announcement['forumid'];
                
$announcementidlink iif(!$vboptions['oneannounce'] , "&amp;announcementid=$announcement[announcementid]");

                eval(
'$announcebits .= "' fetch_template('forumdisplay_announcement') . '";');
        }
    
    
// end announce bit hack 
find, near the top:
PHP Code:
// pre-cache templates used by all actions
$globaltemplates = array(
    
'search_forums',
    
'search_results',
    
'search_results_postbit'// result from search posts
    
'threadbit'// result from search threads
    
'newreply_reviewbit_ignore'
); 
replace with:
PHP Code:
// pre-cache templates used by all actions
$globaltemplates = array(
    
'search_forums',
    
'search_results',
    
'search_results_postbit'// result from search posts
    
'threadbit'// result from search threads
    
'newreply_reviewbit_ignore',
    
'forumdisplay_announcement'
); 
then in template search_results, add where you want them:
PHP Code:
<if condition="$announcebits">
    <
table class="tborder" cellpadding="$stylevar[cellpadding]cellspacing="$stylevar[cellspacing]border="0" width="100%" align="center" style="margin:$stylevar[cellpadding]px 0px $stylevar[cellpadding]px 0px">
        <
tr>
            <
td class="tcat" colspan="2">
                
$vbphrase[announcements]
            </
td>
        </
tr>
        
$announcebits
    
</table>
</if> 
That should do you

Edit: clarified the instructions.
Thanks Jeroen--that worked!

I just have to mess with placing the announcebits code where I want it in the search results and tweaking layout, but otherwise it's working perfectly. It's OK if announcements for individual forums show up in the search results--since "New Posts" is powered from search.php, we want members to be able to see all forum announcements anyway.
Reply With Quote
  #5  
Old 11-14-2004, 01:42 PM
Ianomed's Avatar
Ianomed Ianomed is offline
 
Join Date: Oct 2004
Location: The Netherlands
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent, mind showing off a screenie when you've tweaked it to your taste?
Reply With Quote
  #6  
Old 01-13-2005, 12:21 AM
n_wattam n_wattam is offline
 
Join Date: Nov 2004
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

very nice... was looking for something like this my self. However is there a way i can edit the code so only the GLOBAL ANNOUNCEMENTS are show???

cheers
Reply With Quote
  #7  
Old 01-13-2005, 12:46 AM
n_wattam n_wattam is offline
 
Join Date: Nov 2004
Posts: 39
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Done it...

Id you only want the global accouncement displayed then

From
PHP Code:
eval('$announcebits .= "' fetch_template('forumdisplay_announcement') . '";'); 
To
PHP Code:
if ($announcement['forumid'] == -1) {
    eval(
'$announcebits .= "' fetch_template('forumdisplay_announcement') . '";'); 

Reply With Quote
  #8  
Old 01-13-2005, 12:57 AM
Ianomed's Avatar
Ianomed Ianomed is offline
 
Join Date: Oct 2004
Location: The Netherlands
Posts: 112
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

that's the one

alternatively you could modify the query:

replace:
Code:
                WHERE startdate <= " . (TIMENOW - $vboptions['hourdiff']) . "
                        AND enddate >= " . (TIMENOW - $vboptions['hourdiff']) . "
with:
Code:
                WHERE forumid = -1 AND startdate <= " . (TIMENOW - $vboptions['hourdiff']) . "
                        AND enddate >= " . (TIMENOW - $vboptions['hourdiff']) . "
then only global announces will be read from the DB to start with
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 11:12 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.04686 seconds
  • Memory Usage 2,313KB
  • 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
  • (2)bbcode_code
  • (14)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete