Vote Buttons...

mucka_tbfm

Mucka Jay
We have 17 categories and we only want the vote button visible in one category at a time. Is this an easy thing to do before we start trying to take the code apart?
 

mucka_tbfm

Mucka Jay
Right, we thought we'd be clever and get parabola theme for one category and parabola red for the rest. From the front end of the VL we have parabola red as the default theme and heat 01 we have parabola. Take a look what happens though, when you click into the stats/more info of the heat 01 links the theme goes back to parabola red. In skins and categories we set heat 01 to parabola so not sure what we are doing wrong.
 

Basti

Administrator
Staff member
The theme per category is only for the rankings, maybe another to put on the todo list. to make the details page also like that. Not sure...

As for the Vote button, do mean the vote button on the details page?
 

Basti

Administrator
Staff member
Well you have a vote button on the details page.
Iam not really sure what you try to archive

to make a vote button ( the one on the details page ) visible only if the category equals xx, make a simple plugin.

Folder: CustomVoteDisplay
In there
- blank index.htm
- details_build_page.php

Code:
 $TMPL['custom_vote_button'] = ''; 
if ($TMPL['category'] == 'heat 01')
{
    $TMPL['custom_vote_button'] = "<a href=\"{$TMPL['list_url']}/index.php?a=in&u={$TMPL['username']}\" class=\"stats_vote\" rel=\"nofollow\">VOTE</a>";
}
- folder languages
----- in that folder blank index.htm
----- english.php
Code:
<?php
 
if (!defined('VISIOLIST')) {
  die("This file cannot be accessed directly.");
}
 
?>
Then replace the vote button you have in your stats.html already with {$custom_vote_button}
and only the members listed under cat heat 01 will have that vote button.

The same can be done on the rankings, but instead of details_build_page.php you would make a file called rankings_compile_stats.php
Code:
 $TMPL['custom_vote_button'] = ''; 
if ($TMPL['cat_exist'] && $TMPL['cat_exist'] == 'heat 01')
{
    $TMPL['custom_vote_button'] = "<a href=\"{$TMPL['list_url']}/index.php?a=in&u={$TMPL['username']}\" class=\"stats_vote\" rel=\"nofollow\">VOTE</a>";
}
Then you can use {$custom_vote_button} on table_top_row.html etc and it only displays on the defined category
 

mucka_tbfm

Mucka Jay
Let me explain the full works of what we are trying to do...

We have 10 categories in total. We only want one category per week open to voting. The other 9 are for viewing info only until it is their turn for the voting. So we thought having 2 skins would work. One with the vote button for the voting category and the other skin for the other 9 categories.
 

mucka_tbfm

Mucka Jay
That worked a treat thank you! A few more custom bits to do to this one then we can show you the results before we go live with the site. Last time out (using Aardvark) we had over 4m hits on the website and the list itself had 1/4m hits in 2 weeks!
 

mucka_tbfm

Mucka Jay
I've tried to use the same method to display/hide the buttons on the gateway page - because even if vote buttons aren't available on the details page, sites can change the url to the gateway page to include their username and grab votes that way... (and they will!)

I've created a new folder in Plugins called CustomGateway (does it matter what name I use?) and included a blank index.htm and languages folder all as per above..

I've made a gateway_build_page.php (again, not sure if I have to use a specific name?) with code very similar to that on the details_build_page.php above:

Code:
$TMPL['custom_gateway'] = '';
if ($TMPL['category'] == 'Heat 01')
{
    $TMPL['custom_gateway'] = "<a href=\"{$TMPL['list_url']}\" class=\"visio_button large_button_red\" <span>Enter without voting</span></a><a href=\"{$TMPL['list_url']}/index.php?a=in&amp;u={$TMPL['username']}&amp;sid={$TMPL['sid']}\" class=\"visio_button large_button_green\" <span>Enter and vote</span></a>";
}
..and used {$custom_gateway} in gateway.html in place of the vote button code.. not working, no buttons displayed for any categories. Am I way off mark with this?
 

Basti

Administrator
Staff member
Nope that is wrong.
First off, you can use the same plugin as last time.

In there make a file called in_gateway.php

This hook, is usually used to display more member info or something on the gateway, but we can use this one well, to simply redirect the member to main website if he is not in the allowed category, so he dont even see the gateway page
Code:
if($TMPL['category'] != 'Heat 01') {
    header("Location: {$CONF['list_url']}/");
    exit;
}
gateway.html can remain as the default then
 

mucka_tbfm

Mucka Jay
Ah right, thank you - that's very useful. The problem I've got is a site can access the gateway and vote by typing in the url directly - for example:

http://tbfmonline.co.uk/tbfmfactor/vote/index.php?a=in&u=tbfmfactor-652 (this username is in category 'Heat 02' and only 'Heat 01' should be open to voting at the moment).

This is why I think I need to alter the gateway itself. Though I appreciate this is outside of the scope of the what visiolist is intended for.
 

Basti

Administrator
Staff member
Nope with the instructions above, if he is of a not allowed category such as heat 02, and he type the voting url and hits enter ( or follow a vote link - both are the same in programing, so it doesnt matter ), he simply gets redirected to main page, hes not seeing the gateway at all. So he can not vote

If you do that quick you will see what i mean
 

mucka_tbfm

Mucka Jay
No that isn't true. Heat 01 is the only category open for voting. Baleful Creed is in Heat 02. Clicking from www.tbfmonline.co.uk/tbfmfactor/vote on their 'click here to vote' or their 'more info' button, yes it just returns them to the index page... BUT if they know the user id (tbfmfactor-652) and then go to the gateway manually by following the pattern for heat 01 then changing the code to http://tbfmonline.co.uk/tbfmfactor/vote/index.php?a=in&u=tbfmfactor-652 they get to the gateway and bypass your code and can still vote. This is then a cheat option for those who spot the obvious window of opportunity. If we can spot it, they will too.
 

Basti

Administrator
Staff member
Well, what can i say. I tested it myself before giving you the code, and DOES work.
You made something wrong or have still old wrong files in ur plugin which you tried on yourself.

The stats links in redirecting for thats member, not the gateway. Like i told you before, php doesnt care if you follow a link or type the url yourself.
Looks like you have that redirect in the wrong file. The redirect which currently happens is not from my code, thats certains.

Not sure if you understood me correctly, looks like you added my redirect to details_compile_details.php , not in_gateway.php like i said. We want the gateway do redirect, not the details page like you did
 
Top