PDA

View Full Version : Posticons exlusive to forums. NO STYLE editing!!!


tehcake
05-18-2005, 10:00 PM
This has been done before, but I've yet to see it released here. I was desperate to have this for my forums which has a lot of posticons.

This hack allows you to make posticons useable in only forums you specify. I'm no PHP expert, and I find it amazing how I pulled this off (Had a little help from someone to get it working correctly.), so you won't be able to set the settings through admincp yet. Instead, you have to manually do some changse in your MySQL database for each posticon.

Step 1 MySQL
First, you'll have to go to the icon table in your MySQL database. Create a field called iconforums in the table. Then edit each posticon (phpMyAdmin you'll have to click on the BROWSE tab in the table to edit the fields.), add the forumids to the iconforums field, seperating each forumid with only a comma.

Step 2
Now you'll have to edit your includes/functions_newpost.php.
FIND
SELECT iconid, iconpath, title

REPLACE WITH
SELECT iconid, iconpath, title, iconforums


FIND
while ($icon = $DB_site->fetch_array($icons))

{

ADD BELOW
$forumid = $foruminfo[forumid];
$forums = explode(',',$icon[iconforums]);
if (in_array($forumid,$forums))
{

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

ADD BELOW
}

FINISH! Enjoy you're cleaner forums. :)

Blackbeard
05-19-2005, 05:47 AM
Sorry stupid Q but do you have a screenie of this one please.

Jenta
05-19-2005, 05:59 AM
you know when u create a thread or post?
u have the icons u can use for that thread or post

this makes it so some icons will only show up in certain forums and hence can only be used in those forums

i have the perfect use for this, a coding forum where there are icons based on what code your thread is about
i find people using those icons in off topic :/

thanks

Oblivion Knight
05-19-2005, 06:25 AM
Is it possible to do this per style instead of using replacements (which is what I'm currently doing)? :)

Jenta
05-19-2005, 06:32 AM
perhaps, i have the wrong format for iconforums?
nothing is showing up

perhaps its this line?
`iconforums` varchar(100) NOT NULL default '',


CREATE TABLE `icon` (
`iconid` smallint(5) unsigned NOT NULL auto_increment,
`iconforums` varchar(100) NOT NULL default '',
`title` varchar(100) NOT NULL default '',
`iconpath` varchar(100) NOT NULL default '',
`imagecategoryid` smallint(5) unsigned NOT NULL default '0',
`displayorder` smallint(5) unsigned NOT NULL default '1',
PRIMARY KEY (`iconid`)
) TYPE=MyISAM AUTO_INCREMENT=22 ;

--
-- Dumping data for table `icon`
--

INSERT INTO `icon` VALUES (1, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'News', 'images/icons/icon1.gif', 4, 1);
INSERT INTO `icon` VALUES (2, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Read This', 'images/icons/icon2.gif', 4, 1);
INSERT INTO `icon` VALUES (3, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Idea', 'images/icons/icon3.gif', 2, 21);
INSERT INTO `icon` VALUES (4, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Important!', 'images/icons/icon4.gif', 2, 30);
INSERT INTO `icon` VALUES (5, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Question', 'images/icons/icon5.gif', 2, 20);
INSERT INTO `icon` VALUES (6, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Cool', 'images/smilies/cool.gif', 2, 10);
INSERT INTO `icon` VALUES (7, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Smile', 'images/smilies/smile.gif', 2, 6);
INSERT INTO `icon` VALUES (8, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Angry', 'images/smilies/mad.gif', 2, 9);
INSERT INTO `icon` VALUES (9, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Unhappy', 'images/smilies/frown.gif', 2, 8);
INSERT INTO `icon` VALUES (10, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Big Smile', 'images/smilies/biggrin.gif', 2, 10);
INSERT INTO `icon` VALUES (11, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Red face', 'images/smilies/redface.gif', 2, 10);
INSERT INTO `icon` VALUES (12, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Wink', 'images/smilies/wink.gif', 2, 7);
INSERT INTO `icon` VALUES (13, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Thumbs down', 'images/icons/icon13.gif', 2, 25);
INSERT INTO `icon` VALUES (14, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Thumbs up', 'images/icons/icon14.gif', 2, 26);
INSERT INTO `icon` VALUES (15, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Very Important!', 'images/buttons/report.gif', 4, 1);
INSERT INTO `icon` VALUES (16, '2,3,4,5,6,7,8,10,11,12,13,14,15', 'Extremely Important!', 'images/icons/important.gif', 4, 4);

any ideas on the proper row structure?

ps, heres the code
as u can see its exactly as ur instructions say...

// original SELECT iconid, iconpath, title
$icons = $DB_site->query("
SELECT iconid, iconpath, title, iconforums
FROM " . TABLE_PREFIX . "icon AS icon
WHERE imagecategoryid NOT IN (0$badcategories)
ORDER BY imagecategoryid, displayorder
");

if (!$DB_site->num_rows($icons))
{
return false;
}

$numicons = 0;
$show['posticons'] = false;

while ($icon = $DB_site->fetch_array($icons))
{
// hack
$forumid = $foruminfo[forumid];
$forums = explode(',',$icon[iconforums]);
if (in_array($forumid,$forums))
{
// hack end
$show['posticons'] = true;
if ($numicons % 7 == 0 AND $numicons != 0)
{
$posticonbits .= "</tr><tr><td>&nbsp;</td>";
}

$numicons++;

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

eval('$posticonbits .= "' . fetch_template('posticonbit') . '";');
// hack
}
// hack end

}

boo.3
05-19-2005, 10:37 AM
screen shot?

tehcake
05-19-2005, 02:05 PM
Sorry Jenta, but I'm not really a PHP/MySQL person, so I went into phpMyAdmin and did it all by hand instead of using a query. I don't know if it's the problem, but maybe it's the CREATE part because the icon table already exists?

Allan
05-19-2005, 03:52 PM
Not bad yes, but could you put instruction in a .txt file, please

You have no image has to be proposed with this hack also ?

Jenta
05-19-2005, 04:44 PM
Sorry Jenta, but I'm not really a PHP/MySQL person, so I went into phpMyAdmin and did it all by hand instead of using a query. I don't know if it's the problem, but maybe it's the CREATE part because the icon table already exists?
the create code is just my dump of the table, i didnt use it to actually add ur row
its only to show the rows and what is in each



`iconforums` varchar(100) NOT NULL default '',
this is the row you say to create
can you look at yours and see if its the same?

Jenta
05-19-2005, 04:47 PM
argh, no automerge double post :rolleyes:

anyways....

for those wanting an image, heres one straight from this forum
these are post icons
this hack lets u set which forum each post icon will appear in
its the same as setting an icon category that only certain usergroups can use but its forum bases instead of usergroup based


here's a scenario that might help some understand

lets say you run a decorating forum with different forums

one forum is for gardens and stuff
you have post icons like - rakes and wheelbarrows

then you have another forum about kitchens
you have icons like - cups and refrigerators

then u have a forum where people talk about everyday life - off topic
u dont want the cups, refrigirators, rakes or wheelbarrrow appearing there

opps, just say he added some icons
nm :)

tehcake
05-20-2005, 04:35 AM
Well, I didn't use varchar. I used mediumtext, but I should've used smalltext. I don't know if that will help.

Renee
05-23-2005, 06:42 PM
Hmm, if I add the forumid to iconforums the icon which is added on iconforums don't displayed on all forum not just the added forumid :ermm:

Clayton
06-06-2005, 12:57 PM
this is a really good idea

is anyone able to add more clarity to it, please?

Is this working correctly? How many of you have got it working? Is it possible to have a txt file for all in one instruction?

would be appreciated

thank you

nexialys
06-06-2005, 01:03 PM
this is only a semi-hack... usually, the protocol would need to give you a complete hack, where per example, each posticon is set in the admincp with a new field where admins add the forumids, so you don't have to edit your tables...

Clayton
06-06-2005, 01:15 PM
thanks nexialys

this is a nifty idea, it would be great if someone could finalise it

will wait in anticipation

Thanks

G