vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Post Icons - drop down list (good for lots of icons!) (https://vborg.vbsupport.ru/showthread.php?t=62562)

Gary King 03-15-2004 10:00 PM

Post Icons - drop down list (good for lots of icons!)
 
This hack will put all the post icons into a dropdown list instead, which will save lots of space especially if you have lots of post icons available (or WANT to have a lot of post icons available ;))

Look at attached screenshot to see how it looks like :)
If you have a suggestion, let me know! :)

Anyways, here we go :)

Please make sure that all your icons have a title because this title will be shown in the dropdown menu! Otherwise it will be blank; it will still work and people can select it, but it doesn't help in knowing what the icon will show :)

Instructions

Open up includes/functions_newpost.php and find
PHP Code:

        if ($seliconid == $iconid)
        {
            
$iconchecked HTML_CHECKED;
            
$selectedicon = array('src' => $iconpath'alt' => $alttext);
        }
        else
        {
            
$iconchecked '';
        } 

Replace with
PHP Code:

    if ($seliconid == $iconid
    { 
        if (
$show['dropdownicons']) 
        { 
            
$iconselect " selected"
        } 
        else 
        { 
            
$iconchecked HTML_CHECKED
            
$selectedicon = array('src' => $iconpath'alt' => $alttext); 
        } 
    } 
    else 
    { 
        if (
$show['dropdownicons']) 
        { 
            
$iconselect ''
        } 
        else 
        { 
            
$iconchecked ''
        } 
    } 

Find:
PHP Code:

    $show['posticons'] = false

Below, add
PHP Code:

    $show['dropdownicons'] = 1;

    if (
$show['dropdownicons'])
    {
        
$posticondropdown '<option value="0">' $vbphrase[no_icon] . '</option>';

    } 

Find:
PHP Code:

        eval('$posticonbits .= "' fetch_template('posticonbit') . '";'); 

Below, add
PHP Code:

        eval('$posticondropdown .= "' fetch_template('posticon_dropdown') . '";'); 

Open up posticons template and find
HTML Code:

                                <td width="12%" nowrap="nowrap"><label for="rb_iconid_0"><input type="radio" name="iconid" value="0" id="rb_iconid_0" tabindex="1" onclick="swap_posticon(null)" $iconchecked />$vbphrase[no_icon] &nbsp; &nbsp;</label></td>
                                $posticonbits

Replace it with
HTML Code:

                                <if condition="$show['dropdownicons']"><td><select name="iconid" id="iconid" onchange="changeImage(this.value)">$posticondropdown</select> <img id="posticonimage" /></td><else /><td width="12%" nowrap="nowrap"><label for="rb_iconid_0"><input type="radio" name="iconid" value="0" id="rb_iconid_0" tabindex="1" onclick="swap_posticon(null)" $iconchecked />$vbphrase[no_icon] &nbsp; &nbsp;</label></td>$posticonbits</if>
Find
HTML Code:

        // -->
Above, add
HTML Code:

        <if condition="$show['dropdownicons']">
function changeImage(selVal)
{
if (selVal != 0)
{
 document.getElementById('posticonimage').src = selVal;
}
else
{
document.getElementById('posticonimage').src = 'clear.gif';
}
}
        </if>

Create a new template called posticon_dropdown with the following content:
HTML Code:

<option value="$iconpath"$iconselect>$alttext</option>
All done! :) Now if you ever want to turn this off and use the old way of viewing post icons, then just change $show['dropdownicons'] = 1; in includes/functions_newpost.php to $show['dropdownicons'] = 0; (basically just change 1 to 0.)

I hope you enjoy this hack :p

Owen 03-16-2004 07:59 PM

how much good is this if it doesnt show the actual icons in the list?

Gary King 03-16-2004 08:15 PM

If someone has the Javascript where I can display the image depending on the value selected, then I would be more than happy to add it in :)

Owen 03-16-2004 08:22 PM

I dont think its possible with regular drop down menu's... Maybe its possible to use one of those vb3 dropdown menu's?

Gary King 03-16-2004 08:30 PM

Nevermind I got it :) I will add it in a sec :)

Gary King 03-16-2004 08:39 PM

Okay updated :) It now shows the icons - BUT, it will only work when icons are in the images/icons/ folder and in the correct file format, for now. So it will work with default vB3 icons. If you add any new icons, just make sure they are the same format and same folder.

alkatraz 03-16-2004 08:48 PM

cool hack!

Pikok 03-17-2004 12:20 AM

Quote:

Originally Posted by Gary W
Okay updated :) It now shows the icons - BUT, it will only work when icons are in the images/icons/ folder and in the correct file format, for now. So it will work with default vB3 icons. If you add any new icons, just make sure they are the same format and same folder.

Why not use this in includes/functions_newpost.php:
PHP Code:

        if ($seliconid == $iconid)
        {
            if (
$show['dropdownicons'])
            {
                
$iconselect " selected";
            }
            else
            {
                
$iconchecked HTML_CHECKED;
                
$selectedicon = array('src' => $iconpath'alt' => $alttext);
            }
        }
        else
        {
            if (
$show['dropdownicons'])
            {
                
$iconselect '';
            }
            else
            {
                
$iconchecked '';
            }
        } 

This in the posticons template:
Code:

        function changeImage(selVal)
        {
                if (selVal != 0)
                {
                        document.getElementById('posticonimage').src = selVal;       
                }
                else
                {
                        document.getElementById('posticonimage').src = 'clear.gif';
                }
        }

This in the posticon_dropdown template:
Code:

<option value="$iconpath"$iconselect>$alttext</option>
That would use the correct SRC path for all icons and would also have the icon pre-selected if the post already had one (i.e. when editing).

Gary King 03-17-2004 12:48 AM

Quote:

Originally Posted by Pikok
Why not use this in includes/functions_newpost.php:
PHP Code:

        if ($seliconid == $iconid)
        {
            if (
$show['dropdownicons'])
            {
                
$iconselect " selected";
            }
            else
            {
                
$iconchecked HTML_CHECKED;
                
$selectedicon = array('src' => $iconpath'alt' => $alttext);
            }
        }
        else
        {
            if (
$show['dropdownicons'])
            {
                
$iconselect '';
            }
            else
            {
                
$iconchecked '';
            }
        } 

This in the posticons template:
Code:

        function changeImage(selVal)
        {
                if (selVal != 0)
                {
                        document.getElementById('posticonimage').src = selVal;       
                }
                else
                {
                        document.getElementById('posticonimage').src = 'clear.gif';
                }
        }

This in the posticon_dropdown template:
Code:

<option value="$iconpath"$iconselect>$alttext</option>
That would use the correct SRC path for all icons and would also have the icon pre-selected if the post already had one (i.e. when editing).

Okay I integrated your steps now :)

gmarik 03-17-2004 03:15 AM

This one is good for coding similiar hacks, great one!


All times are GMT. The time now is 09:57 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.01191 seconds
  • Memory Usage 1,796KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (4)bbcode_code_printable
  • (5)bbcode_html_printable
  • (8)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete