vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   "Random Post Icon" possible? (https://vborg.vbsupport.ru/showthread.php?t=172320)

Dorign 03-07-2008 02:54 AM

"Random Post Icon" possible?
 
When posting a new topic and/or replying to a topic, you have the option of selecting an icon. By default, "No Icon" is selected.

I was wondering if there was a simple way to have the "No Icon" renamed to "Random Icon" and have the thread automatically select a random post icon from the posticon folder.

My reasoning is almost none of my users will pick an icon, and if I remove the "No Icon" button, then all the post icons will look the same. It looks ugly on the forum.

Here's an example.

http://www.ev0lnetwork.net/sigs/temp/ewexample.jpg

The only one using post icons is me, so there's only one selected in the image.

Is this possible? How would I go about doing this?

Dorign 03-11-2008 04:06 AM

Bump

Dismounted 03-11-2008 05:29 AM

Possible. You'll have to override the setting in newreply and choose an id at random.

GameWizard 03-11-2008 05:41 AM

Wouldn't it make more sense to just apply a default icon? As if you have a random one selected, it would turn into a mish mash of random colors and shit all over which will look worse than no icons.

Dorign 03-11-2008 11:43 PM

Quote:

Originally Posted by GameWizard (Post 1462056)
Wouldn't it make more sense to just apply a default icon? As if you have a random one selected, it would turn into a mish mash of random colors and shit all over which will look worse than no icons.

I disagree. Being as the entire site is monochrome green in the first place, a tiny mesh of 16x16 colorful icons in one column would add enough to capture the eye. I know a lot about colors and how they're used to capture the eye because I majored in Art. Sadly, I didn't major in coding and I have no idea how to get done what I want. :o

GameWizard 03-12-2008 08:31 AM

Well then it looks like were in the same preticament. Although I am slightly more proficient in coding, but also have a good eye for design. In your case, you'll need a pretty unique script as I have never seen such a thing anywhere else, best of luck. Maybe consider requesting it in the Paid section if you're willing to dish out some cash for it.

sunilvarma 03-13-2008 03:49 AM

Here's a way to do this. As this involves editing newthread.php, not everyone may like this solution.

Anyways, here's what to do:

(UPDATED) In newthread.php, FIND:
Code:

$newpost['iconid'] =& $vbulletin->GPC['iconid'];
REPLACE WITH:
Code:

if($vbulletin->GPC['iconid'] != 0){
                $newpost['iconid'] =& $vbulletin->GPC['iconid'];
        }
        else{               
                $icons_list = array();
                $iconids = $db->query_read("SELECT iconid FROM icon");
                while($row=mysql_fetch_assoc($iconids)){
                        array_push($icons_list, $row);
                }
                $newpost['iconid'] = array_rand($icons_list) + 1;
        }

That should do it.

If you want to change the "No icon" text to "Random Icon" just edit the posticons template:

FIND:
Code:

$vbphrase[no_icon]
REPLACE WITH:
Code:

Random Icon
If anyone can implement this with a plugin, please show me how. And also let me know if the code is efficient.

Dismounted 03-13-2008 05:32 AM

You can hook a plugin further down the code to overwrite the variable. You also don't really need a query, just do a random number between 1-10 or something.

sunilvarma 03-13-2008 05:56 AM

if a posticon is deleted its ID is no longer valid right? so i used a query to get all the IDs in the table instead of generating a random number directly.

could you explain a little about hooking a plugin?

Dismounted 03-13-2008 06:06 AM

Well, you could always make a setting that lets the admin list ids that they want for the random icon. As for the plugin, find a plugin before the post is submitted, but after the varuable has been initialised.


All times are GMT. The time now is 10:54 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.01040 seconds
  • Memory Usage 1,738KB
  • 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
  • (1)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
  • (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