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!

Owen 03-17-2004 06:32 AM

ah nifty, forgot to think you could load the image next to it.

Good Work.

Fibe 03-20-2004 11:53 AM

For some reason, i now have dropdown AND the original list to chose from.

Any idea what could be wrong?

Gary King 03-20-2004 01:14 PM

Quote:

Originally Posted by Fibe
For some reason, i now have dropdown AND the original list to chose from.

Any idea what could be wrong?

You didn't follow instructions properly then :)

The code you did wrong was in the posticons template.

Fibe 03-20-2004 02:00 PM

hmm i just double checked and everything is like it should be. afaik :(
Quote:

<if condition="$show['posticons']">
<script type="text/javascript">
<!--
function swap_posticon(imgid)
{
out = fetch_object("display_posticon");
img = fetch_object(imgid);
if (img)
{
out.src = img.src;
out.alt = img.alt;
}
else
{
out.src = "$vboptions[cleargifurl]";
out.alt = "";
}
}
<if condition="$show['dropdownicons']">
function changeImage(selVal)
{
if (selVal != 0)
{
document.getElementById('posticonimage').src = selVal;
}
else
{
document.getElementById('posticonimage').src = 'clear.gif';
}
}
</if>
// -->
</script>
<fieldset class="fieldset" style="margin:10px 0px 0px 0px">
<legend>$vbphrase[post_icons]</legend>
<div style="padding:$stylevar[formspacer]px">
<table cellpadding="0" cellspacing="$stylevar[cellspacing]" border="0" width="95%">
<tr>
<td colspan="15"><div style="margin-bottom:$stylevar[formspacer]px">$vbphrase[may_choose_icon_for_message]:</div></td>
</tr>
<tr>
<if condition="$show['dropdownicons']"><td><select name="iconid" id="iconid" onchange="changeImage(this.value)">$posticondropdo wn</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>


$posticonbits
<if condition="$show['addedspan']"><td colspan="$remainingspan">&nbsp;</td></if>
</tr>
</table>
</div>
</fieldset>
<else />
<input type="hidden" name="iconid" value="0" />
</if>

Gary King 03-20-2004 04:06 PM

Quote:

Originally Posted by Fibe
hmm i just double checked and everything is like it should be. afaik :(

Can I please see your forums then.

Fibe 03-20-2004 04:22 PM

<a href="http://forums.soi-guild.org" target="_blank">http://forums.soi-guild.org</a>

test/test u can login with !

and thanks !

Gary King 03-20-2004 04:26 PM

Weird, maybe a problem with Gold? Although I sincerely doubt it; it looks like it has something to do with the conditionals but that should be fine.

How it is right now is that you can change between the two, but to fix this for you, simply do the following then:

open the posticons template, 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
And then just delete that :)

Fibe 03-20-2004 04:27 PM

u are god ! thanks man.
one last question when u click on new thread

no icon is picked this gif file logol shows up. how can i get rid of this?"

Gary King 03-20-2004 04:32 PM

What do you mean? Please make a screenshot and circle it.

Fibe 03-20-2004 04:38 PM

As you can see they are still there :( And i circled the gif thing.


Code:

<if condition="$show['dropdownicons']"><td><select name="iconid" id="iconid" onchange="changeImage(this.value)">$posticondropdown</select> <img id="posticonimage" /></td></if>
thats whats i got in posticon template now.

Gary King 03-20-2004 05:57 PM

Wow, you have something really messed up there; you removed the code from the template but it still shows? :eek:

Make sure you modify the correct styleset.

Fibe 03-20-2004 06:02 PM

i don't understand lol i added posticons template in the SOI style. (which is style i use) and they are sitll there lol.

what about that image btw ? and thanks loads ! i really want this to work since it's godly, i am not giving up :)

Gary King 03-20-2004 06:38 PM

I can't believe what's going on, something is broken :p
I can't really help you much farther in terms of removing the post icons radio buttons because it shouldn't be there in the first place.

Fibe 03-20-2004 07:21 PM

LOL i turned the 1 into a 0 in the functions_newpost.php

and now all icons are there twice

Gary King 03-20-2004 07:26 PM

Yep that's why it should be 1.

Fibe 03-20-2004 07:39 PM

ok not sure how when and why, but i fixed it !

Just that little graphics shows up. If i pick another icon and then go back to " no icon" it's no longer there.

Gary King 03-20-2004 07:45 PM

Yep it's a Javascript thing, it's not really that important but if someone wants to try to fix it to be my guest :)

Tim Wheatley 03-20-2004 10:11 PM

Quote:

Originally Posted by Gary W
Can I please see your forums then.

Works perfectly with vB3 Gold here. :up:

Just a note for future users, in order for the text to show in the list, you must have edited the titles/names in your cp here:
http://www.yourdomain.com/admincp/im...ify&table=icon

Gary King 03-20-2004 10:30 PM

Quote:

Originally Posted by Tim Wheatley
Works perfectly with vB3 Gold here. :up:

Just a note for future users, in order for the text to show in the list, you must have edited the titles/names in your cp here:
http://www.yourdomain.com/admincp/im...ify&table=icon

Good idea about notifying that, I added in the post :)

wrongful 03-21-2004 04:27 AM

Does anyone know a way to make the "No Icon" selection show the default icon?

Fibe 03-25-2004 10:40 AM

oh my god....

I thought everything worked fine, but when i select and icon when posting it doesn't showup !

Anyone have any clue what i could have messed up this time?

noonespecial 04-02-2004 06:29 AM

Quote:

Originally Posted by Fibe
oh my god....

I thought everything worked fine, but when i select and icon when posting it doesn't showup !

Anyone have any clue what i could have messed up this time?

exact same issue ..

everything looks like it works, i can select the icon, it shows up next to it .. then i push post, and no icon appears in the forum.. ?!

Jolten 04-02-2004 07:44 AM

Quote:

Originally Posted by Gary W



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>


Where do these steps go??

noonespecial 04-02-2004 07:48 AM

Quote:

Originally Posted by Jolten
Where do these steps go??

posticon template.

Jolten 04-02-2004 08:02 AM

Thanks noonespecial.

I've got the same issue as others. It appears to work. But back in thread view no icons change. They only appear to change when you select them from the menu.

noonespecial 04-02-2004 09:26 AM

Quote:

Originally Posted by Jolten
Thanks noonespecial.

I've got the same issue as others. It appears to work. But back in thread view no icons change. They only appear to change when you select them from the menu.

exactly.. slightly annoyed at the moment, but i am hoping the author will be on tomorrow, and sort this all out .. so, for now this remains uninstalled with a sincere hope to get it fixed and working, because I have way too many icons on my website .. and this would save so much bandwidth, loading time ..

Jolten 04-03-2004 06:36 PM

Any chance for a fix Gary?

Gary King 04-03-2004 10:25 PM

Quote:

Originally Posted by Jolten
Any chance for a fix Gary?

I'm working on it, just real busy :)

noonespecial 04-03-2004 10:26 PM

Quote:

Originally Posted by Gary W
I'm working on it, just real busy :)

yay!!!.. i've been working on it too, so far no luck .. and well, i suck. so that's prolly why.

Jolten 04-09-2004 09:22 PM

This one works like a charm for me:

https://vborg.vbsupport.ru/showthrea...ght=post+icons


All times are GMT. The time now is 03:00 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.01531 seconds
  • Memory Usage 1,881KB
  • 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
  • (5)bbcode_code_printable
  • (8)bbcode_html_printable
  • (8)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)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