PDA

View Full Version : v3arcade Favorites Mod


amykhar
11-28-2005, 10:00 PM
As written, the favorites list is generated by the number of times a game is played. This modification changes that behavior so that users can select their own favorite games. It includes the ability to add and remove games from the favorites list.

I am not offering support for this modification. It is provided as-is. It is working fine for me, but I'm not guaranteeing that it will work for you.

yoyoyoyo
11-29-2005, 01:24 PM
nice work as usual

Snake
11-29-2005, 01:58 PM
Oh yes. Thanks for the hack amy.

amykhar
11-29-2005, 03:21 PM
No problem. I write stuff that I need and don't mind sharing :)

monstergamer
11-29-2005, 03:31 PM
sorry i get Parse error: parse error in /home/httpd/vhosts/monstergamer.net/httpdocs/vb/arcade.php on line 518

Vizionz
11-29-2005, 03:39 PM
i get a parse error on line 518
was there an update to the arcade i dont know about ? that could be the reason for that error now

amykhar
11-29-2005, 03:56 PM
Get the new zip. There was an else{ missing and the first installers probably knew enough php (as they should) to fix it themselves ;)

Gizmo5h1t3
11-29-2005, 03:58 PM
sorry amy, this just doesnt work.

installed EXACTLY as stated...
all seems ok, till u actually click on the "add to favourtes" link
then u get a blank page....

Oblivion Knight
11-29-2005, 05:29 PM
* Oblivion Knight gives Amy a hug!
Thank you! This is much better than the current default.. :D

michaelbenson
11-29-2005, 06:08 PM
Thanks this looks like a brilliant addition.
Would it be possible for say the Favourites category to be displayed as defualt instead of the Random category instead

amykhar
11-29-2005, 06:26 PM
Sure it would Michael. You just have to change the code to make that happen. ;)

FleaBag
11-29-2005, 06:30 PM
LOL. :D Nice work.

amykhar
11-29-2005, 06:40 PM
This is why I hate releasing code :D I always forget stuff in the directions. I left out the code chunk from the top of the file.


Find:
---------
$footer = construct_phrase($vbphrase['arcade_end'], $vbulletin->options['arcadeimages']) . $footer;
----------
Add After:
---------
if ($_REQUEST['do']=='addfav')
{
$vbulletin->input->clean_array_gpc('r', array(
'gameid' => TYPE_INT
));

$favuser = $vbulletin->userinfo[userid];
$favgame = $vbulletin->GPC['gameid'];
if($favuser AND $favgame)
{
// Make sure it's not in the user's favorites
$eaalreadythere = $db->query_first("SELECT gameid FROM " .TABLE_PREFIX."eaarcade_favorites WHERE userid=$favuser and gameid=$favgame");
if(!$eaalreadythere)
{
$db->query_write("INSERT INTO " . TABLE_PREFIX . "eaarcade_favorites (userid, gameid) VALUES ($favuser,$favgame)");
}
}
// Go to the favorites page
$vbulletin->url = 'arcade.php?categoryid=2';
standard_redirect($vbphrase['favorite_added'], true);
}

if ($_REQUEST['do']=='delfav')
{
$vbulletin->input->clean_array_gpc('r', array(
'gameid' => TYPE_INT
));

$favuser = $vbulletin->userinfo[userid];
$favgame = $vbulletin->GPC['gameid'];
if($favuser AND $favgame)
{
// Make sure it's in the user's favorites
$eaalreadythere = $db->query_first("SELECT * FROM " .TABLE_PREFIX."eaarcade_favorites WHERE userid=$favuser AND gameid=$favgame");
if($eaalreadythere)
{
$db->query_write("DELETE FROM " . TABLE_PREFIX . "eaarcade_favorites WHERE userid=$favuser AND gameid=$favgame");
}
}
// Go to the favorites page
$vbulletin->url = 'arcade.php?categoryid=2';
standard_redirect($vbphrase['favorite_removed'], true);
}

---------

Vizionz
11-29-2005, 07:02 PM
now it works perfect thanks amy

monstergamer
11-29-2005, 07:51 PM
worrks now

...installed...

nintendo
11-29-2005, 08:48 PM
* Oblivion Knight gives Amy a hug!

Thank you! This is much better than the current default.. :D

Try to get John to make this the default version. This is what we all wanted, not the current crummy one that's not a favorites section at all.

Vizionz
11-29-2005, 08:51 PM
yeah this and the users online you did oblivion should be default settings

Vizionz
11-29-2005, 08:53 PM
it would be also nice to have a stats page where it shows the most played games the top gamers and top ten most played players. < that one i mean total games played in the arcade by that user.

amykhar
11-30-2005, 12:33 AM
You guys do realize that John's probably never going to read this thread and it might be better to discuss your arcade wish list somewhere John'll read it, right?

Lea Verou
11-30-2005, 01:21 AM
Installed and works flawlessly. Thank you :)

On little suggestion: Check if the user has added the game when he is browsing other categories and display the remove link instead of the add one even if the game is already added ;)

amykhar
11-30-2005, 01:23 AM
I didn't do that because I didn't want to bulk up the query, Michelle. But, I may do it in the future.

Vizionz
11-30-2005, 01:25 AM
You guys do realize that John's probably never going to read this thread and it might be better to discuss your arcade wish list somewhere John'll read it, right?
i know that :) but i like you to see ideas too since your a great coder amy :) and maybe you would find use in something and decide to do it for yourself then shair the code like usual :P

Lea Verou
11-30-2005, 01:27 AM
I didn't do that because I didn't want to bulk up the query, Michelle. But, I may do it in the future.

I suspected that :) You could add it as an option though so that smaller forums can take advantage of it :)

Oblivion Knight
11-30-2005, 06:28 AM
I didn't do that because I didn't want to bulk up the query, Michelle. But, I may do it in the future.I remember trying to handle that with a cache in the 3.0.x version, but it was an absolute nightmare.. :speechless:

Gizmo5h1t3
11-30-2005, 06:11 PM
might be wise to add that this wont work with the alternative layout hack released on here......

amykhar
11-30-2005, 11:22 PM
I guess you just added that :D I haven't seen the alternative layout mod.

wcbryant
12-01-2005, 06:54 AM
Does anyone have this working in v3a 1.0.2 with OK's "Who's Online" and the "Leader Board" hacks? I know that's a stretch, but thought I'd try. I seem to get a blank white page, and wonder if it's a conflict with any of the above.

amykhar
12-01-2005, 12:55 PM
A bit of experimentation on my site shows that performance isn't taking a big hit when I do this. So... I have updated the code to dynamically show if a game is a favorite or not on the category lists.

If you have already installed the mod, here is how to upgrade:

1. Find:

else if ($vbulletin->GPC['categoryid']==2)
{
// Favorites
$gamecountquery = ("SELECT * FROM " . TABLE_PREFIX."eaarcade_favorites
WHERE userid=" . $vbulletin->userinfo['userid'] . "
GROUP BY userid ASC");
$gamecount = $db->num_rows($gamecountquery);

$perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);

// set defaults
sanitize_pageresults($gamecount, $pagenumber, $perpage, 100, $vbulletin->options['gamesperpage']);

$start = (int)($perpage*$pagenumber)-$perpage;

$pagenav = construct_page_nav($pagenumber, $perpage, $gamecount, 'arcade.php?' . $vbulletin->session->vars['sessionurl'], ""
. (!empty($vbulletin->GPC['categoryid']) ? "&amp;categoryid=" . $vbulletin->GPC['categoryid'] : "")
. (!empty($vbulletin->GPC['perpage']) ? "&amp;pp=$perpage" : "")
);

$games = $db->query_read("SELECT eaarcade_favorites.gameid, arcade_games.*, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "eaarcade_favorites AS eaarcade_favorites
LEFT JOIN " . TABLE_PREFIX . "arcade_games AS arcade_games ON (arcade_games.gameid=eaarcade_favorites.gameid)
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categor yid)
WHERE eaarcade_favorites.userid=" . $vbulletin->userinfo['userid'] . " AND arcade_games.title IS NOT NULL
" . iif($bitfieldcheck, "AND $bitfieldcheck") . "
ORDER BY eaarcade_favorites.gameid DESC
LIMIT $start,".$vbulletin->options['gamesperpage']);
} else {


Replace with:
-----------

else if ($vbulletin->GPC['categoryid']==2)
{
// Favorites
$gamecountquery = ("SELECT * FROM " . TABLE_PREFIX."eaarcade_favorites
WHERE userid=" . $vbulletin->userinfo['userid'] . "
GROUP BY userid ASC");
$gamecount = $db->num_rows($gamecountquery);

$perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);

// set defaults
sanitize_pageresults($gamecount, $pagenumber, $perpage, 100, $vbulletin->options['gamesperpage']);

$start = (int)($perpage*$pagenumber)-$perpage;

$pagenav = construct_page_nav($pagenumber, $perpage, $gamecount, 'arcade.php?' . $vbulletin->session->vars['sessionurl'], ""
. (!empty($vbulletin->GPC['categoryid']) ? "&amp;categoryid=" . $vbulletin->GPC['categoryid'] : "")
. (!empty($vbulletin->GPC['perpage']) ? "&amp;pp=$perpage" : "")
);

$games = $db->query_read("SELECT eaarcade_favorites.*, arcade_games.*, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "eaarcade_favorites AS eaarcade_favorites
LEFT JOIN " . TABLE_PREFIX . "arcade_games AS arcade_games ON (arcade_games.gameid=eaarcade_favorites.gameid)
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categor yid)
WHERE eaarcade_favorites.userid=" . $vbulletin->userinfo['userid'] . " AND arcade_games.title IS NOT NULL
" . iif($bitfieldcheck, "AND $bitfieldcheck") . "
ORDER BY eaarcade_favorites.gameid DESC
LIMIT $start,".$vbulletin->options['gamesperpage']);
} else {

-----------

Find:

$games = $db->query_read("SELECT arcade_games.*, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "arcade_games AS arcade_games
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categor yid)
" . iif($vbulletin->GPC['categoryid']!=-1, "WHERE arcade_games.categoryid=" . $vbulletin->GPC['categoryid'] . iif($bitfieldcheck, " AND $bitfieldcheck"), iif($bitfieldcheck, "WHERE $bitfieldcheck")) . "
ORDER BY title ASC
LIMIT $start, " . $vbulletin->options['gamesperpage']);


Replace with:

$games = $db->query_read("SELECT arcade_games.*, favorites.favid AS favid, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "arcade_games AS arcade_games
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
LEFT JOIN " . TABLE_PREFIX . "eaarcade_favorites AS favorites ON (favorites.gameid=arcade_games.gameid)
LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categor yid)
" . iif($vbulletin->GPC['categoryid']!=-1, "WHERE favorites.userid=". $vbulletin->userinfo[userid]." AND arcade_games.categoryid=" . $vbulletin->GPC['categoryid'] . iif($bitfieldcheck, " AND $bitfieldcheck"), iif($bitfieldcheck, "WHERE $bitfieldcheck")) . "
ORDER BY title ASC
LIMIT $start, " . $vbulletin->options['gamesperpage']);


In your arcade_game_bit template, Replace the code block you added previously with:

<br /> <if condition="$game[favid]"><a href="arcade.php?do=delfav&gameid=$game[gameid]">$vbphrase[arcadedelfav]</a><else /><a href="arcade.php?do=addfav&gameid=$game[gameid]">$vbphrase[arcadeaddfav]</a></if>


(Note: only the conditional changed in the template.)

Maagic
12-01-2005, 02:28 PM
I'm getting

Parse error: parse error, unexpected T_ELSE in /home/(deleted)/public_html/forum/arcade.php on line 442

Oblivion Knight
12-01-2005, 05:35 PM
Does anyone have this working in v3a 1.0.2 with OK's "Who's Online" and the "Leader Board" hacks? I know that's a stretch, but thought I'd try. I seem to get a blank white page, and wonder if it's a conflict with any of the above.Nope, this works fine with the Who's Online and Leader Board addons.. ;)


might be wise to add that this wont work with the alternative layout hack released on here......Once I've updated the Alternative Layout mod, I'll provide some instructions for adding this mod to it..

vedman
12-03-2005, 07:15 PM
might be wise to add that this wont work with the alternative layout hack released on here......
I take it you're not referring to the template addition? :) That can be mangled to suit the alternate layout hack...

I use the alternate layout.. and games don't show up at all in specific categories (though "All" and "Random" games do appear).

Looks like it's this specific query in arcade.php:


$games = $db->query_read("SELECT arcade_games.*, favorites.favid AS favid, user.username, arcade_categories.catname FROM " . TABLE_PREFIX . "arcade_games AS arcade_games
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (arcade_games.highscorerid=user.userid)
LEFT JOIN " . TABLE_PREFIX . "eaarcade_favorites AS favorites ON (favorites.gameid=arcade_games.gameid)
LEFT JOIN " . TABLE_PREFIX . "arcade_categories AS arcade_categories ON (arcade_games.categoryid=arcade_categories.categor yid)
" . iif($vbulletin->GPC['categoryid']!=-1, "WHERE favorites.userid=". $vbulletin->userinfo[userid]." AND arcade_games.categoryid=" . $vbulletin->GPC['categoryid'] . iif($bitfieldcheck, " AND $bitfieldcheck"), iif($bitfieldcheck, "WHERE $bitfieldcheck")) . "
ORDER BY title ASC
LIMIT $start, " . $vbulletin->options['gamesperpage']);

I'm guessing it's this...


LEFT JOIN " . TABLE_PREFIX . "eaarcade_favorites AS favorites ON (favorites.gameid=arcade_games.gameid)

Since there are no games in the favorites table initially, wouldn't that mean it doesn't match any games in the games table (and thus, none are displayed)? I don't know a lot about sql joins, but if they're anything like where conditions, if part of it doesn't match, it won't return any rows.

I'm sure it's something I'm doing wrong, since this mod obviously works for some people. One strange thing though - I don't see how it relates to the alternative layout mod (since that mod doesn't alter the "get games for specific category" query, above).

Despite all of that, it looks like a great mod, it makes v3arcade even more awesome (I'm an ibPro convert). Thanks a ton! Can't wait to get it working.

vedman
12-03-2005, 10:02 PM
Ok, got it fixed. Hopefully this is useful to someone who has the same issue I had.

I downloaded the zip file this morning and installed it as is, so any additional code in this thread is not taken into account.

This is only for those using the alternate layout, and whose games are not showing up in any user-defined categories, after installing the Favorites mod.

However, I did add a line to arcadeadmin.php which deletes favorites whenever a game is removed... I guess anyone could use that. :nervous:

This is the first time I've written instructions for a hack, hopefully it makes sense.

.

dan35
12-06-2005, 04:17 AM
I don't use the alternate layout, but the games are not showing up in specific categories after installing the Favorites mod.

Use your fix and it works ;)

Thanks Amy and Vedman!

FROGGYJ
12-08-2005, 10:03 PM
installed~

Snake
12-09-2005, 08:32 AM
Is this going to work fine on v3.5.2?

amykhar
12-09-2005, 10:35 AM
Given that it doesn't change anything about VB, yes. This only changes arcade code.

Snake
12-09-2005, 10:50 AM
Ah alright then.

dieselpowered
12-11-2005, 07:21 PM
Ok, got it fixed. Hopefully this is useful to someone who has the same issue I had.

I downloaded the zip file this morning and installed it as is, so any additional code in this thread is not taken into account.

This is only for those using the alternate layout, and whose games are not showing up in any user-defined categories, after installing the Favorites mod.

However, I did add a line to arcadeadmin.php which deletes favorites whenever a game is removed... I guess anyone could use that. :nervous:

This is the first time I've written instructions for a hack, hopefully it makes sense.

.

Forgive this ignorant question, however, are we supposed to do this fix as well as the edits from the hack Amy posted?

I wonder why not not everyone reported that the games were not showing up in their specific categories...wouldn't that have affected everyone?

vedman
12-11-2005, 09:04 PM
Forgive this ignorant question, however, are we supposed to do this fix as well as the edits from the hack Amy posted?
My fix is based on the mod zip file only. The edits from the mod that were posted change it up a little, but not much.

My hack basically sets the $games query (for specific categories) back to the original code, and adds a small query to get the favorites seperately. It doesn't change what is called in the template, so it would actually fix the category problems with those not using the alt. layout mod, as long as you don't touch the template change.

Unless you understand PHP and see what changed, I'd recommend going one route or the other.

I wonder why not not everyone reported that the games were not showing up in their specific categories...wouldn't that have affected everyone?
That's a good question. I installed this mod right after installing v3arcade, so maybe the fact that none of my games had been played had something to do with it?

dieselpowered
12-11-2005, 09:27 PM
Thanks for the response...ok well I had already done the edits from the zip...and then saw you fix, so I did the edits you specified, therefore, I have edits from your file as well as Amy's. Should I upload a fresh arcade.php and only do your edits?

vedman
12-11-2005, 10:13 PM
Should I upload a fresh arcade.php and only do your edits?
Not quite.. my edits were done after installing the mod from the zip file. So, my hack does not include instructions to change a couple of things that do need to be changed in arcade.php.

If you're having the problem where games are not showing up in specific categories, I would suggest starting with a fresh arcade.php, applying the edits as instructed in the arcadefav.zip file, and then applying the edits specified in my hack.

dieselpowered
12-11-2005, 10:23 PM
That is what I did :) All is well!! Thanks

Crapaddict
12-18-2005, 09:05 AM
[...]
I wonder why not not everyone reported that the games were not showing up in their specific categories...wouldn't that have affected everyone?
On my board they only show up in their specific categories, if they are added to the favorites category.
This includes games from the default categories, not only user defined categories.

Now i wonder if it is something i did wrong, or do more people have this problem?

nintendo
12-30-2005, 09:21 PM
Check
http://www.v3arcade.com/forums/showthread.php?p=6845#post6845

amykhar
12-31-2005, 01:21 AM
There is a fix. It's posted in this thread.

Oblivion Knight
12-31-2005, 07:20 AM
There is a fix. It's posted in this thread.Yup, and the fix works great! :D

Cheers Vedman.

Snake
12-31-2005, 01:07 PM
May I have the direct link please?

Oblivion Knight
12-31-2005, 04:41 PM
<a href="https://vborg.vbsupport.ru/showpost.php?p=839446&postcount=32" target="_blank">https://vborg.vbsupport.ru/showp...6&postcount=32</a>

Snake
12-31-2005, 11:02 PM
Thanks, you da man! :D

caimakale
01-02-2006, 03:40 AM
I downloaded this hack and installed it. I had the problem with games not showing up in the proper category so I installed the hack later in this thread to fix it.

I do have a problem though with the arcade_favorites_fix.txt file. The I don't have the code in my arcade_game_bit template that it says I need to modify.

The only hacks installed on my arcade is the arcade champion which doesn't change the arcade_game_bit template, and this one.

I assume it's because I don't have the alternate layout installed??? Is there any changes that need to be made to the original game_bit template?

Oblivion Knight
01-02-2006, 04:48 AM
I do have a problem though with the arcade_favorites_fix.txt file. The I don't have the code in my arcade_game_bit template that it says I need to modify.You don't need to make this change, only the text colour was changed from the original instructions on the remove favorite link in an attempt to make it stand out more.

nintendo
01-02-2006, 12:16 PM
There is a fix.

Oh no there isn't!!

You are using Oblivion Knight's alternate layout

How about updating the main hack so it works for everyone instead of only the few people that installed the alternate layout hack.

Oblivion Knight
01-02-2006, 05:40 PM
Oh no there isn't!!Oh yes there is.!
I posted a link to it in post #48.. :)


How about updating the main hack so it works for everyone instead of only the few people that installed the alternate layout hack.The fix works regardless of the Alternate Layout mod being installed or not.. Amy has already said that she's too busy to support her hacks, and the fix may not be added to her instructions for a while.

vedman
01-02-2006, 08:32 PM
How about updating the main hack so it works for everyone instead of only the few people that installed the alternate layout hack.
It would take me a couple of minutes to do it, and I would, but you're being rude. Much like in the real world, demanding favors will get you nowhere.

Just don't do the template change in my hack, and it'll work. I'm sure you can figure it out.

YLP1
01-15-2006, 03:15 PM
I am confused..... does the zip file contain the revised code in the posts?

I am using the alternate layout.

Thanks in advance

sinoeu
02-05-2006, 10:53 PM
Great job! But the only appeatance of add/remove favorite link in normal mod game list limits its work :surprised: Don't you think it should also be in the game playing page and the highsore page?

sinoeu
02-05-2006, 10:55 PM
Once I've updated the Alternative Layout mod, I'll provide some instructions for adding this mod to it..

And is it possible now?