Welcome to Geeklog Saturday, October 21 2017 @ 12:58 am EDT


Status: offline

BizzoMephisto655

Forum User
Newbie
Registered: 21/02/2006
Posts: 1
Thanks to Dirk for making the link block. I just modified it a little to show hits and description for those who wanted it.
see it in action here www.tardisshed.com

thanks again Dirk...

bizzo

PHP Formatted Code
function phpblock_blogroll ()
{
    global $_CONF, $_TABLES;

    // configuration options:

    $cat = 'xxxxxxxxxxxxx';        // Category to take links from
    $directlink = false; // Use direct links (true) or portal.php (false)
    $random = false;     // Random order (true) or sort by $sort (false)
    $sort = 'date';     // Sort by ... e.g. 'date', 'title', 'url'

    // === you shouldn't need to change anything below this line ==============
    $retval = '';

    $result = DB_query ("SELECT lid,url,title,description,hits FROM {$_TABLES['links']} WHERE category = '$cat'" . COM_getPermSql ('AND') . " ORDER BY $sort");
    $numLinks = DB_numRows ($result);

    $links = array ();
    for ($i = 0; $i < $numLinks; $i++) {
        $A = DB_fetchArray ($result);

        if ($directlink) {
            $url = $A['url'];
            $link = '<a href="' . $url . '">';
           
        } else {
            $url = $_CONF['site_url']
                 . COM_buildUrl ('/portal.php?what=link&item=' . $A['lid']);
            $link = '<a href="' . $url . '" title="' . $A['url'] . '">';
         
        }
        $links[] = $link . stripslashes ($A['title']) . '</a>' . ' (' . ($A['hits']) . ')' . '<br><i>' . ($A['description']) . '<br><br></i>';
    }

    if (count ($links) > 0) {

        if ($random) {
            $min = 0;
            $max = count ($links) - 1;

            $newlist = array ();
            do {
                $r = rand ($min, $max);

                if (!empty ($links[$r])) {
                    $newlist[] = $links[$r];
                    unset ($links[$r]);
                }

                if ($r == $min) {
                    $min = $r + 1;
                } else if ($r == $max) {
                    $max = $r - 1;
                }
                if ($min == $max) {
                    if (!empty ($links[$min])) {
                        $newlist[] = $links[$min];
                    }
                    break;
                }
            }
            while ($max > $min);

            $retval = COM_makeList ($newlist, 'list-blogroll');
        } else {
            $retval = COM_makeList ($links, 'list-blogroll');
        }
    }

    return $retval;
}

 

Status: offline

1000ideen

Forum User
Full Member
Registered: 04/08/2003
Posts: 1289
Will it still work with GL 1.5 ?

Status: offline

::Ben

Forum User
Full Member
Registered: 14/01/2005
Posts: 1569
Location:la rochelle, France
This one work with Geeklog 1.5.0

PHP Formatted Code

function phpblock_blogroll ()
{
    global $_CONF, $_TABLES;

    // configuration options:

    $cat = 'xxxxxxxxxxxxx'; // cid to take links from (e.g. If category is Geeklog Sites, cid is geeklog-sites
    $directlink = false; // Use direct links (true) or portal.php (false)
    $random = false;     // Random order (true) or sort by $sort (false)
    $sort = 'date';     // Sort by ... e.g. 'date', 'title', 'url'

    // === you shouldn't need to change anything below this line ==============
    $retval = '';

    $result = DB_query ("SELECT lid,url,title,description,hits FROM {$_TABLES['links']} WHERE cid = '$cat'" . COM_getPermSql ('AND') . " ORDER BY $sort");
    $numLinks = DB_numRows ($result);

    $links = array ();
    for ($i = 0; $i < $numLinks; $i++) {
        $A = DB_fetchArray ($result);

        if ($directlink) {
            $url = $A['url'];
            $link = '<a href="' . $url . '">';
           
        } else {
            $url = $_CONF['site_url']
                 . COM_buildUrl ('/portal.php?what=link&item=' . $A['lid']);
            $link = '<a href="' . $url . '" title="' . $A['url'] . '">';
         
        }
        $links[] = $link . stripslashes ($A['title']) . '</a>' . ' (' . ($A['hits']) . ')' . '<br><i>' . ($A['description']) . '<br><br></i>';
    }

    if (count ($links) > 0) {

        if ($random) {
            $min = 0;
            $max = count ($links) - 1;

            $newlist = array ();
            do {
                $r = rand ($min, $max);

                if (!empty ($links[$r])) {
                    $newlist[] = $links[$r];
                    unset ($links[$r]);
                }

                if ($r == $min) {
                    $min = $r + 1;
                } else if ($r == $max) {
                    $max = $r - 1;
                }
                if ($min == $max) {
                    if (!empty ($links[$min])) {
                        $newlist[] = $links[$min];
                    }
                    break;
                }
            }
            while ($max > $min);

            $retval = COM_makeList ($newlist, 'list-blogroll');
        } else {
            $retval = COM_makeList ($links, 'list-blogroll');
        }
    }

    return $retval;
}
 


::Ben
I'm available to customise your themes or plugins for your Geeklog CMS

Status: offline

1000ideen

Forum User
Full Member
Registered: 04/08/2003
Posts: 1289
Thanks Exclamation This tool should become part of the link plugin.

Status: offline

beewee

Forum User
Full Member
Registered: 05/08/2003
Posts: 969
Location:The Netherlands, where else?
Quote by: 1000ideen

Thanks Exclamation This tool should become part of the link plugin.



It would be nice if the Link plugin would offer the ability to assign an block to a certain link category, or let the link categories follow the story topics as well. Or just one single block already assigned to a pre-installed category Blogroll for a start.

I believe the coder from Glinks had something like that on his new features list. This piece of code would be insufficient since you have to put this in lib-custom.php and edit it to assign it to a category.
Dutch Geeklog sites about camping/hiking: www.kampeerzaken.nl | www.campersite.nl | www.caravans.nl | www.caravans.net

All times are EDT. The time is now 12:58 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content