Print Thread
[PANEL] Top 10 Weblinks
KasteR
Since I just put this snippet together, there's no locale file that I setup. There are 2 spots with hard-coded text, in English.
  • Panel Title (Top 10 Weblinks) on line 3
  • Empty result from query (No weblinks have been created yet.) on line 11

Download source  Code
<?php
$result = dbquery("SELECT weblink_url,weblink_name,weblink_count,weblink_id FROM ".DB_WEBLINKS." WHERE ".groupaccess('weblink_cat_access')." ORDER BY weblink_count DESC LIMIT 10");
openside('Top 10 Weblinks');
if (dbrows($result)) {
   echo '<ol>';
      while($data = dbarray($result)) {
         echo '<li><a href="'.BASEDIR.'weblinks.php?weblink_id='.$data['weblink_id'].'" alt="'.$data['weblink_name']."&nbsp;&dash;&nbsp;".$data['weblink_url'].'" title="'.$data['weblink_name']."&nbsp;&dash;&nbsp;".$data['weblink_url'].'">'.trimlink($data['weblink_url'], 23)."</a>&nbsp;&#40;".$data['weblink_count']."&#41;".'</li>';
      }
   echo '</ol>';
} else {
   echo "<div style='text-align:center'>No weblinks have been created yet.</div>\n";
}
closeside();
?>



Actually there may be an issue with the SQL syntax. I'll post an update as soon as I can.
Edited by KasteR on 01-30-2015 15:24
 
penehoff
When my site starts getting regular web link posters that might be a good little snippet
 
Sumer
Hi,

This is exceptionally decent and wonderful post.
I am very happy joined this forum.
I like it exceptionally much....!!!!
Thanks alot...
Sumer
 
penehoff
Doesnt work
 
NetriX
The query needs to join with weblink_cats table.

Just use code below, it will work.. Unless you MUST HAVE group access...

It will show all links.

Download source  Code
$result = dbquery("SELECT weblink_url,weblink_name,weblink_count,weblink_id FROM ".DB_WEBLINKS." ORDER BY weblink_count DESC LIMIT 10");
openside('Top 10 Weblinks');
if (dbrows($result)) {
   echo '<ol>';
      while($data = dbarray($result)) {
         echo '<li><a href="'.BASEDIR.'weblinks.php?weblink_id='.$data['weblink_id'].'" alt="'.$data['weblink_name']."&nbsp;&dash;&nbsp;".$data['weblink_url'].'" title="'.$data['weblink_name']."&nbsp;&dash;&nbsp;".$data['weblink_url'].'">'.trimlink($data['weblink_url'], 23)."</a>&nbsp;&#40;".$data['weblink_count']."&#41;".'</li>';
      }
   echo '</ol>';
} else {
   echo "<div style='text-align:center'>No weblinks have been created yet.</div>\n";
}
closeside();



Edited by NetriX on 02-28-2015 12:59
 
penehoff
Parse error: syntax error, unexpected '<' in /home/indepen1/public_html/penehoff/WorldWide/themes/templates/panels.php(74) : eval()'d code on line 1
 
NetriX
My bad, I was evaluating the code in custom pages. You can directly add it to php based panel now. The snippet above was updated to reflect changes.

Tested and working on my end. Thumb Up

Basically, just removed <?php and ?>..
 
penehoff
That works but removes my footer

go look
http://worldwide....tbands.com
 
NetriX
You're right, however, I don't believe the script above is causing it as its' closed properly.

Some element on your website did not close properly. Where at is the million dollar question.

I'll investigate more when I get back, out for pizza!! rock
 
penehoff
Has to be the panel .. i disable it the footer re-appears
 
NetriX
o.k. yeah, I suppose closeside(); got removed when I edited it.. ahh..

Fixed, working!! Try again with updated code.
 
penehoff
cheers Coffee
 
Gillette
tooltip (balloon text) displaying
-Contributor
-? could you update this Brandon?
 
KasteR
Hey Matt,
Are you wanting to display an author of the weblink? I looked through the database, and found that this data is not actually recorded/stored in the weblinks table.

  • weblink_id
  • weblink_name
  • weblink_description
  • weblink_url
  • weblink_cat
  • weblink_datestamp
  • weblink_count

When a weblink is submitted, the data is first stored in the submissions table. There's a column called submit_user which records their user id. Once approved by an administrator, the user id is not transferred to anywhere that will be kept within the weblinks table.
 
Gillette
Yeah, your right KasteR,
I was looking at that, today.
so im thinking about tooltip hover, display description /

and possibly insert table to collect username of the submitter ?? i unno.. now

thanks for bringing that to my attn., I should have seen that, been working on a few infusions, maybe a balmers peak backfire happen to me...
 
KasteR
Haha, no problem man. Sometimes I pass the apex myself Grin

Might be a cool idea for an infusion or something though Thumb Up
 
Gillette
I think (off topic) but you was on key with your script and it can be used within alot of pulls from sql.
thank you for sharing man Smile
 
NetriX
I'll package this sooner or later, unless someone else wants to with correct locales.

php-fusion.us/forum/attachments/weblinks.jpg

Download source  Code
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) PHP-Fusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Author: Brandon Davis (NetriX) & KasteR (Kaster.us)
| PHP-Fusion USA NSS - PHP-Fusion.us
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
add_to_head('<style type="text/css">
<!--
   .tooltip {
   display:none;
   position:absolute;
   border:1px solid #333;
   background-color:#161616;
   border-radius:5px;
   padding:10px;
   color:#fff;
   font-size:12px Arial;
}
-->
</style>

<script type="text/javascript">
$(document).ready(function() {
// Tooltip only Text
$(\'.masterTooltip\').hover(function(){
        // Hover over code
        var title = $(this).attr(\'title\');
        $(this).data(\'tipText\', title).removeAttr(\'title\');
        $(\'<p class="tooltip"></p>\')
        .text(title)
        .appendTo(\'body\')
        .fadeIn(\'slow\');
}, function() {
        // Hover out code
        $(this).attr(\'title\', $(this).data(\'tipText\'));
        $(\'.tooltip\').remove();
}).mousemove(function(e) {
        var mousex = e.pageX + 20; //Get X coordinates
        var mousey = e.pageY + 10; //Get Y coordinates
        $(\'.tooltip\')
        .css({ top: mousey, left: mousex })
});
});
</script>');
$result = dbquery("SELECT * FROM ".DB_WEBLINKS." ORDER BY weblink_count DESC LIMIT 0,10");
openside('Top 10 Weblinks');
if (dbrows($result)) {
   echo '<ol>';
      while($data = dbarray($result)) {
         echo '<li><a href="'.BASEDIR.'weblinks.php?weblink_id='.$data['weblink_id'].'" alt="'.$data['weblink_name']."&nbsp;&dash;&nbsp;".$data['weblink_url'].'" class="masterTooltip" title="'.$data['weblink_description']."&nbsp;&dash;&nbsp;".$data['weblink_url'].'">'.trimlink($data['weblink_name'], 23)."</a>&nbsp;&#40;".$data['weblink_count']."&#41;".'</li>';
      }
   echo '</ol>';
} else {
   echo "<div style='text-align:center'>No weblinks have been created yet.</div>\n";
}
closeside();


NetriX attached the following image:
weblinks.jpg
 
Gillette
I can work the locales, Thanks for adding to this panel Brandon!
 
KasteR
I found that the balloon tip is not displaying. Looking at the code, the tooltip css is commented out. Also, I figured there should be an update to control weblinks without descriptions to not display the dash. I've also updated the code to include locale option. My webserver has been intermittent though...I'll update soon if nobody else does.

EDIT:
So the reason it wasn't displaying for me was due to the theme I was using. ".tooltip" was already given CSS attributes per my stylesheet. I've changed the name of the class, so this conflict will not occur for those who use bootstrap. But I did modify the code slightly so that weblinks without a description will not show as "- whatever.com". They will just show as "whatever.com" if that's all that's there.
KasteR attached the following file:
weblinks_top10_panel.zip [2.17kB / 316 Downloads]

Edited by KasteR on 03-23-2015 13:15
 
Jump to Forum: