Plugin help

top50servers

Active Member
Hello guys/Mark,
I'm doing a plugin where I display a tag on details page and on rankings page, I've managed to display tag on details page, but I have no idea how to do it for rankings and details page.

This is what I have on details_compile_details.php:
PHP:
$result = $DB->query("SELECT `acf_squidhq_display` FROM {$CONF['sql_prefix']}_sites WHERE username = '{$TMPL['username']}' AND `acf_squidhq` = 1", __FILE__, __LINE__);
while($row = $DB->fetch_array($result)){
if($row['acf_squidhq_display'] == "Yes"){

  $TMPL['squid'] = '<a href="https://squidhq.com/" rel="nofollow" title="SquidHQClient" target="_blank"><button class="btn btn-default btn-blue pull-right squidhd"> <img src="../skins/parabola/child/img/squidhqsmall.png"> <span>SQUIDHQ SERVER</span></button></a>';
}
}
1. Is this the proper way of displaying stuff on details page.
2. How can i display on rankings per user to check if user have Yes or isset

Thanks,
Top50
 

Mark

Administrator
Staff member
That is one way of doing it, but I don't think you need to query the database again. Custom field values should already be available in the TMPL[] array. They should also be available in the table_ templates without needing to query the database further.

try this and see what happens:

in your table_top_row template simply enter this to see what is available:

acf_squidhq_display = {$acf_squidhq_display}<br>
acf_squidhq = {$acf_squidhq}

you can do the same in your details/stats template.

Once you see if the template variable values are already available, all your plugin would need to do is something like:

Code:
if($TMPL['acf_squidhq_display'] == "Yes"){
$TMPL['squid'] = '<a href="https://squidhq.com/" rel="nofollow" title="SquidHQClient" target="_blank"><button class="btn btn-default btn-blue pull-right squidhd"> <img src="../skins/parabola/child/img/squidhqsmall.png"> <span>SQUIDHQ SERVER</span></button></a>';
}
this way you save yourself the expense of hitting the database on each page-load.

hope that helps
 

top50servers

Active Member
Hi Mark,

Managed to get it working! Thank you!

Side note:

The search results tables seem to be loaded in a different way, when using the same method to get the button to display on those it would display on the CORRECT SERVER and all servers after it (even if they where not the rank). Know a fix?
 

Mark

Administrator
Staff member
The search results tables seem to be loaded in a different way, when using the same method to get the button to display on those it would display on the CORRECT SERVER and all servers after it (even if they where not the rank). Know a fix?
Sounds like the custom fields variable needs to be initialized (or emptied) in the loop. I would need FTP access to help find a workaround for that one, but it sounds like something that should be fixed in the core... I just haven't got much time at the moment to experiment with setting this up on my test list. feel free to private message me FTP login if you would like this solved sooner, rather than later.
 
Top